【思维】洛谷P1319 压缩技术——灵活运用for循环

P1319 压缩技术 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)

题解 P1319 【压缩技术】 - RedContritio 的博客 - 洛谷博客 (luogu.com.cn)

#include<bits/stdc++.h>
using namespace std;
int n,p,q,t;
int main()
{
    for(cin>>n;cin>>p;t^=1){
        for(;p--;q++){
            if(q==n) q=0&putchar('\n'); 
            putchar('0'+t);
        }
    }
    return 0;
}

 

posted @ 2021-07-08 09:42  infocodez  阅读(54)  评论(0)    收藏  举报