ACM ICPC Vietnam National Second Round D X = X + X % 100

来源:互联网 发布:程序员工具箱 编辑:程序博客网 时间:2024/04/29 03:30
//ACM ICPC Vietnam National Second Round D////题目大意:////X = X + X % 100.给你一个N和K.求K次操作后N的值////解题思路:////看到N和K都是1e9这种数.想到肯定会有循环节.然后//打表找规律.一开始发现是20一循环.即4的倍数才可以开//始循环,然而太年轻,交了无数发,wrong了无数发.后来发现//10这类的也是有循环4一循环.欣喜的敲了一发,然后还是wrong//这时候,我又想到了00这种特殊的情况,好,又交,又wrong//当然50也要特判啊.25啊,75啊都特判.写完之后,我发现自己太//年轻了,这样就可以过了.还是自己考虑问题不够周全吧.//情况多多,做练习赛的时候并没有做出来.不得不说自己太弱了.//继续加油,FIGHTING!!!#include <cstring>#include <algorithm>#include <iostream>#include <cstdio>#include <cmath>#include <string>#include <vector>#include <queue>#define For(x,a,b,c) for (int x = a; x <= b; x += c)#define Ffor(x,a,b,c) for (int x = a; x >= b; x -= c)#define cls(x,a) memset(x,a,sizeof(x))using namespace std;typedef long long ll;const int MAX_N = 108;const int INF = 0x3f3f3f3f;const ll MOD = 1e6;ll N,K;int a[108];int cnt[108];bool vis[108];int main(){  //  cls(a,0); //打表所用  //  cls(cnt,0);  //  for (int i = 1 ;i < 100;i ++){  //      cls(vis,0);  //      int k = 0;  //      vis[i] = 1;  //      int x = i;  //      x = x + x % 100;  //      int t = x % 100;  //      int c = 1;  //      while(!vis[t]){  //          vis[t] = 1;  //          x = x + x % 100;  //          t = x % 100;  //          c++;  //      }  //      a[i] = x;  //      cnt[i] = c;  //  //  if (i % 10 == 5)  //  //      printf("%d %d %d\n",i,x,c);  //  }    //freopen("1.in","r",stdin);      int kase;    scanf("%d",&kase);    for (int i = 1;i <= kase ;i ++){        scanf("%I64d%I64d",&N,&K);                ll ans = N / 100 * 100;        ll res = N % 100;        if (res == 0){            printf("%I64d\n",N);            continue;        }        if ( res == 50){            printf("%I64d\n", N + 50);            continue;        }        if ( res == 25){            if (K >= 1000000){                printf("%I64d\n",ans + 100);            }            continue;        }        if (res == 75){            if (K >= 1000000){                printf("%I64d\n",ans + 200);            }            continue;        }            if (K < 1000000){            for (int j = 1;j <= K;j ++){                res = res + res % 100;            }            printf("%I64d\n",ans + res);            continue;        }        int c = 0;        if ( res % 10 != 0 || res % 10 != 5){            while((res % 100) % 4){                res += res % 100;                c++;            }            K -= c;            res = res + K / 20 * 1000;            K %= 20;        }        else {            while(((res % 100) / 10) % 2){                res += res % 100;                c++;            }            K -= c;            res = res + K / 4 * 200;            K %= 4;        }        for (int j = 0 ; j < K; j++){            res += res % 100;        }        printf("%I64d\n",ans + res);    }}

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 苹果x变砖头怎么办 oppo手机刷机刷成砖头怎么办 小米刷机变砖头怎么办 网上话费充错怎么办 京东售后过期怎么办? 京东售后不同意怎么办 京东买的电视售后怎么办 淘宝不能照相了怎么办 淘宝手机充值充到空号了怎么办 淘宝店家不退货怎么办 卖家拒绝退货怎么办? 淘宝发大件物流怎么办 快递好几天不动怎么办 微信上没有购物怎么办 天猫客服诈骗怎么办 京东购物受骗怎么办 京东商城诈骗怎么办 安逸花重复扣款怎么办 公司诈骗离职人怎么办 支付宝重复扣款怎么办 微信重复付款怎么办 花呗重复扣款怎么办 淘宝不退款怎么办投诉 淘宝怎么办极速退货 淘宝换货没收到怎么办 淘宝卖货让人换货了怎么办 淘宝换货关闭了怎么办 物流透露客户信息怎么办 淘宝信息泄漏后怎么办 淘宝信息泄漏了怎么办 天猫贷款还不上怎么办 车贷下不来定金怎么办 建行车贷不通过怎么办 天猫介入失败怎么办 天猫投诉没用怎么办 天猫被投诉商标侵权怎么办 虚假发货有天猫红包怎么办 淘宝代购是假货怎么办 闲鱼对方不在怎么办 小米商城退款慢怎么办 小米手机第三方拿货是怎么办