Submission #1688670
Source Code Expand
//
// main.c
// kyopro1016
//
// Created by takumi on 2017/10/16.
// Copyright © 2017年 takumi. All rights reserved.
//
#include <stdio.h>
int beki(int,int);
int main(int argc, const char * argv[]) {
int c[11]={0};
int a,z,q,h,count,p=1,total = 0;
int b[12];
printf(" ");
int m = 0;
scanf("%d",&z);
int zz=z;
while(zz!=0){
zz=zz/10;
m++;
}
//printf("%d\n",m);
for(int i = 0; i<m-1;i++ ){
p=p*2;
}
//printf("%d\n",p);
for(int j=0; j<p; j++){
count = 0;
a=z;
q=j;
for(int k=0; k<m; k++){
b[k]=q%2;
q=q/2;
}
for(int l=0; l<m-1; l++){
if(b[l]==1){
h=a;
a = a/beki(10,l+1-count);
c[l]=h-a*beki(10,l+1-count);
//printf("cl%d\n",c[l]);
//printf("AA%d\n",a);
count = l+1;
}
}
total = total + a;
for(int i2=0;i2<12;i2++){
total = total+c[i2];
c[i2]=0;
}
}
printf("%d\n",total);
return 0;
}
int beki(int a,int b){
int k = 1;
for(int c=0;c<b;c++){
k = k * a;
}
return k;
}
Submission Info
Submission Time |
|
Task |
C - Many Formulas |
User |
etanoru |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1300 Byte |
Status |
WA |
Exec Time |
1 ms |
Memory |
128 KB |
Compile Error
./Main.cpp: In function ‘int main(int, const char**)’:
./Main.cpp:18:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&z);
^
./Main.cpp:49:31: warning: iteration 11u invokes undefined behavior [-Waggressive-loop-optimizations]
total = total+c[i2];
^
./Main.cpp:48:24: note: containing loop
for(int i2=0;i2<12;i2++){
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 300 |
Status |
AC
|
|
Set Name |
Test Cases |
Sample |
|
All |
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, sample_01.txt, sample_02.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
WA |
1 ms |
128 KB |
02.txt |
WA |
1 ms |
128 KB |
03.txt |
WA |
1 ms |
128 KB |
04.txt |
WA |
1 ms |
128 KB |
05.txt |
WA |
1 ms |
128 KB |
06.txt |
WA |
1 ms |
128 KB |
07.txt |
WA |
1 ms |
128 KB |
08.txt |
WA |
1 ms |
128 KB |
09.txt |
WA |
1 ms |
128 KB |
10.txt |
WA |
1 ms |
128 KB |
sample_01.txt |
WA |
1 ms |
128 KB |
sample_02.txt |
WA |
1 ms |
128 KB |