1 solutions
-
0
C :
#include<stdio.h> int Magic(int m); int main() { int m,ret; scanf("%d",&m); ret=Magic(m); if(ret!=1) printf("The sum you calculated is wrong!\n"); return 0; } int Magic(int m) { int a,b,c,n; for(a=1;a<9;a++) { for(b=1;b<9;b++) { for(c=1;c<9;c++) { n=122*a+212*b+221*c; if(m==n) { printf("%d\n",100*a+10*b+c); return 1; } } } } return 0; }C++ :
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> using namespace std; int main() { int n; scanf("%d",&n); for(int a=1;a<=9;++a) { for(int b=0;b<=9;++b) { for(int c=0;c<=9;++c) { if(a*100+c*10+b+b*100+a*10+c+b*100+c*10+a+c*100+a*10+b+c*100+b*10+a==n) { printf("%d",a*100+b*10+c); return 0; } } } } printf("The sum you calculated is wrong!"); return 0; }
- 1
Information
- ID
- 17199
- Time
- 1000ms
- Memory
- 2MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By