杭电1163--9余项定理的例子

# include <iostream>
# include <cstdio>
# include <algorithm>
using namespace std;


int main(){

    int n,a[10009];
    int i,t;

    while(scanf("%d",&n),n!=0){
        int t = 1;
        for(i=0;i<n;i++){
            t=(n*t-1)%9+1;//-1的目的当时9的时候,输出9
        }

        printf("%d\n",t);

    }

    return 0;
}

你可能感兴趣的:(杭电)