标签:style blog http color io os for strong sp
Time Limit: 1000MS
Memory Limit: 25600KB
30分骗分算法
# include<cmath> # include<stdio.h> # include<stack> # include<iostream> # include<algorithm> using namespace std; stack<int>S; const int maxn=10000; int num[maxn]; int A,B,a,m,tot,ok=1,cur; int main(){ scanf("%d%d",&A,&B); if(A%B==0){printf("%d.0",A/B);return 0;} if(A>B){printf("%d.",A/B);A=A%B;ok=0;} a=A; for(int i=1;i<=maxn;i++){ a=a*10; tot++; num[i]=a/B; a=a%B; if(a==0)break; } if(tot<maxn){if(ok)printf("0.");for(int i=1;i<=tot;i++)printf("%d",num[i]);return 0;} int q=1;int t=num[1];for(int i=1;i<=maxn;i++)if(num[i]!=t){q=0;break;} if(q){if(ok)printf("0.");printf("(%d)",num[1]);return 0;} return 0; }
这题很水就是看你想不想得到模拟小数点时
Mod到相同的余数那么与之前余数相同的之间的数十循环的
TMD小学数学老师死的早
标签:style blog http color io os for strong sp
原文地址:http://www.cnblogs.com/zoniony/p/4050923.html