sicily 1020. Big Integer

这道题的关键也就两句话

    for (int i = 0; i < len; ++i)
    {
        ans = (ans*10 + x[i]-'0') % num;
    }

其余也没什么好说的

#include <stdio.h>
#include <string.h>

int getVeryLongNumberMod(char x[],int num){
    int len = strlen(x);
    int ans = 0;
    for (int i = 0; i < len; ++i)
    {
        ans = (ans*10 + x[i]-'0') % num;
    }
    return ans;
}

int main(int argc, char const *argv[])
{
    int size,NumberSize;
    int BaseNumber[400];
    char Total[401] ;
    scanf("%d",&size);
    while (size--) {
        scanf("%d",&NumberSize);
        for (int i = 0; i<NumberSize; i++) {
            scanf("%d",&BaseNumber[i]);
        }
        scanf("%s",Total);
        printf("(");
        for (int i = 0; i<NumberSize; i++) {
            if ( i != NumberSize - 1 ){
                printf("%d,",getVeryLongNumberMod(Total, BaseNumber[i]));
            }else
                printf("%d)\n",getVeryLongNumberMod(Total, BaseNumber[i]));
        }
    }

}

 


posted @ 2016-05-11 21:45  zhou23  阅读(157)  评论(0编辑  收藏  举报