hdu 1230 哪里错了,WA。。。

各位谢谢拉。#include<stdio.h>#define M 200int prime[40] = {1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113};__int64 change(char *str){ int temp,count =0; for(int i=0;str[i]!='\0';i++) if(str[i]==',') count++; __int64 ans =0; for(i=0;str[i]!='\0';i++) { temp =0; for(;str[i]!=',' && str[i]!='\0';i++) temp = temp *10 + str[i]-'0'; ans = (ans+temp) * prime[count--] ; if(str[i]=='\0') return ans; } return ans;}void Output(__int64 ans){ int stack[M],top =0; do { stack[top++] = ans % prime[top+1]; ans /= prime[top]; }while(ans); while(top) { if(top==1) printf("%d\n",stack[--top]); else printf("%d,",stack[--top]); }}int main(){ char a[M],b[M]; while(scanf("%s%s",a,b)!=EOF && !(a[0]=='0' && b[0]=='0') ) { __int64 ans = change(a) + change(b); Output(ans); } return 0;}
2026-12-04 12:08:40
推荐回答(1个)
回答1:

__int64不会溢出么?