zoukankan      html  css  js  c++  java
  • 【模拟】XMU 1055 数七

    题目链接:

      http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1055

    题目大意

      报数游戏,不能报7的倍数和2进制下含有111的数。

      给定n,m(1<=n,m<=20)表示起始位和总人数。报到255为止。能报输出二进制,否则"pass"。

    题目思路:

      【模拟】

      暴力模拟即可。十进制转二进制。

     1 //
     2 //by coolxxx
     3 //
     4 #include<iostream>
     5 #include<algorithm>
     6 #include<string>
     7 #include<iomanip>
     8 #include<memory.h>
     9 #include<time.h>
    10 #include<stdio.h>
    11 #include<stdlib.h>
    12 #include<string.h>
    13 //#include<stdbool.h>
    14 #include<math.h>
    15 #define min(a,b) ((a)<(b)?(a):(b))
    16 #define max(a,b) ((a)>(b)?(a):(b))
    17 #define abs(a) ((a)>0?(a):(-(a)))
    18 #define lowbit(a) (a&(-a))
    19 #define sqr(a) ((a)*(a))
    20 #define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
    21 #define eps (1e-8)
    22 #define J 10000000
    23 #define MAX 0x7f7f7f7f
    24 #define PI 3.1415926535897
    25 #define N 256
    26 using namespace std;
    27 typedef long long LL;
    28 int cas,cass;
    29 int n,m,lll,ans;
    30 string ss;
    31 void change(int x)
    32 {
    33     ss="";
    34     while(x)
    35     {
    36         if(x&1)ss="1"+ss;
    37         else ss="0"+ss;
    38         x>>=1;
    39     }
    40 }
    41 int main()
    42 {
    43     #ifndef ONLINE_JUDGE
    44 //    freopen("1.txt","r",stdin);
    45 //    freopen("2.txt","w",stdout);
    46     #endif
    47     int i,j,k;
    48 //    for(scanf("%d",&cas);cas;cas--)
    49 //    for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
    50 //    while(~scanf("%s",s))
    51     while(~scanf("%d",&n))
    52     {
    53         scanf("%d",&m);
    54         for(i=n;i<N;i+=m)
    55         {
    56             change(i);
    57             if(i%7==0 || ss.find("111")!=-1)puts("pass");
    58             else cout<<ss<<endl;
    59         }
    60     }
    61     return 0;
    62 }
    63 /*
    64 //
    65 
    66 //
    67 */
    千万不要点
  • 相关阅读:
    git 工作流程
    微信小程序 scroll-view 水平滚动使用
    微信小程序 tree组件
    微信小程序各类生命周期
    JS/Jquey 图片链接点击直接下载
    JS/Jquery 表单方式提交总结
    Nodejs 发送邮件 激活邮箱
    搭建Nodejs环境 创建Express应用
    break、continue、return区别
    shell(一)
  • 原文地址:https://www.cnblogs.com/Coolxxx/p/5760393.html
Copyright © 2011-2022 走看看