spoj 362

来源:互联网 发布:网络免费学英语 编辑:程序博客网 时间:2024/06/05 14:12

规律还是比较好找的  大数除法

#include <cstdio>#include <cstring>int len,a[1000],q;int cc[] = {0,1,2,5,9,8,6};bool check(){    for(; q < len; q++)        if(a[q])        return true;    return false;}int mod(int *s){    int t = 0;    for(int i = q; i < len; i++)    {        t *= 10;        t += s[i];        s[i] = t/7;        t %= 7;    }    return t;}int main(){    int t;    scanf("%d",&t);    while(t--)    {        q = 0;        char s[500];        scanf("%s",s);        len = strlen(s);        for(int i = 0; i < len; i++)            a[i] = s[i]-'0';        while(check())            printf("%d", cc[mod(a)]);        puts("");    }    return 0;}


原创粉丝点击