題目鏈接:
http://acm.hdu.edu.cn/showproblem.php?pid=1717
3 0.(4) 0.5 0.32(692307)
4/9 1/2 17/52
這個題目參見百度
http://zhidao.baidu.com/link?url=cJ2IRdzhGzhB3Ct4l0hic1K31tF-tKeb5oI0YlKE5huks_FNDHsNYEfXPfvV1yZTH9XWpU0eOosRlvOlI-MAOa
代碼為:
#include#include const int maxn=10+10; char str[maxn]; int gcd(int a,int b) { return b==0?a:gcd(b,a%b); } int cal1(int x) { int ans=1; for(int i=1;i<=x;i++) ans=ans*10; return ans; } int cal2(int x) { int ans=0; for(int i=1;i<=x;i++) ans=ans*10+9; return ans; } int main() { int t,ok,len,start,end,num; int son,mother,extra; int ans; scanf("%d",&t); while(t--) { ok=1; scanf("%s",str); len=strlen(str); for(int i=0;i