Submission #2249425
Source Code Expand
#include<cstdio> #include<cstring> using namespace std; struct node { int len, a[511]; node() { len=1; memset(a,0,sizeof(a)); } }; node cf(node n1,node n2) { node no; no.len=n1.len+n2.len-1; for(int i=1;i<=n1.len;i++) { for(int j=1;j<=n2.len;j++) { no.a[i+j-1]+=n1.a[i]*n2.a[j]; } } for(int i=1;i<=no.len;i++) { no.a[i+1]+=no.a[i]/10; no.a[i]%=10; } int i=no.len; while(no.a[i+1]>0) { i++; no.a[i+1]=no.a[i]/10; no.a[i]%=10; } while((no.a[i]==0) && (i>1)) i--; no.len=i; return no; } int main() { char st[511]; node no,n1,n2; scanf("%s",st+1);n1.len=strlen(st+1); for(int i=1;i<=n1.len;i++) n1.a[n1.len-i+1]=st[i]-'0'; scanf("%s",st+1);n2.len=strlen(st+1); for(int i=1;i<=n2.len;i++) n2.a[n2.len-i+1]=st[i]-'0'; no=cf(n1,n2); for(int i=no.len;i>=1;i--) printf("%d",no.a[i]); printf("\n"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Code Formula 2015 |
User | luogu_bot5 |
Language | C++ (GCC 5.4.1) |
Score | 100 |
Code Size | 1059 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 128 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:44:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s",st+1);n1.len=strlen(st+1); ^ ./Main.cpp:46:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s",st+1);n2.len=strlen(st+1); ^
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | sample_01.txt, sample_02.txt, test_2_1.txt, test_349_131.txt, test_383_460.txt, test_851_774.txt, test_913_969.txt, test_916_44.txt, test_999_1000.txt, sample_01.txt, sample_02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 1 ms | 128 KB |
sample_02.txt | AC | 1 ms | 128 KB |
test_2_1.txt | AC | 0 ms | 128 KB |
test_349_131.txt | AC | 0 ms | 128 KB |
test_383_460.txt | AC | 0 ms | 128 KB |
test_851_774.txt | AC | 0 ms | 128 KB |
test_913_969.txt | AC | 0 ms | 128 KB |
test_916_44.txt | AC | 0 ms | 128 KB |
test_999_1000.txt | AC | 0 ms | 128 KB |