其他分享
首页 > 其他分享> > poj 1426(同余,bfs,二进制压缩存储,oj系统判定有问题,100k,0ms也能过)

poj 1426(同余,bfs,二进制压缩存储,oj系统判定有问题,100k,0ms也能过)

作者:互联网

#include<iostream>
#include<queue>
//https://blog.csdn.net/lyy289065406/article/details/6647917
using namespace std;
int m[530000];
int main(){
    int i,len,n;
    while(scanf("%d",&n)==1&&n){
        m[1] = 1;
        for(i=2;m[i-1]!=0;i++)
            m[i] = (m[i/2]*10+i%2)%n;
        i--;
        len = 0;
        while(i){
            m[len++] = i%2;
            i /= 2;
        }
        while(len){
            printf("%d",m[--len]);
        }
        printf("\n");
    }
    return 0;
}

 

标签:100k,oj,1426,int,len,while,printf,include,i%
来源: https://www.cnblogs.com/stevenzrx/p/15579322.html