TOJ:2971. Rotating Numbers
来源:互联网 发布:量子破碎剧情 知乎 编辑:程序博客网 时间:2024/06/02 00:13
满满的都是怨念!本来是用的string做的0.4K左右,结果总是Runtime Error SIGSEGV不明觉厉
#include <iostream>#include <cstdio>#include <cstring>using namespace std;typedef long long ll;bool ok(ll x){ll t = x;while (t){if (t % 10 == 0) return 0;t /= 10;}return 1;}int len(ll x){ll t = x;int sum = 0;while (t)sum++, t /= 10;return sum;}void solve(ll x, ll y){int cnt = 0, flag = 1;while (cnt < y){if (ok(x) && flag){y -= cnt;y %= len(x);flag = cnt = 0;}ll t = x % 10, tt = x / 10;while (t && len(t) <= len(tt))t *= 10;x = t + tt;cnt++;}cout << x << endl;}int main(){ll m, n;while (cin >> m >> n)solve(m, n);}
0 0
- TOJ:2971. Rotating Numbers
- TOJ 1477. Binary Numbers
- TOJ 3504 Repeatless Numbers / 深搜
- TOJ 1203.Factoring Large Numbers
- TOJ 2353.Reduced ID Numbers
- TOJ 2931 Raising Modulo Numbers 快速幂
- TOJ 4399 Deal with numbers / 线段树成段更新
- TOJ 3293.A Sequence of Numbers(快速幂取余)
- Rotating Sentences
- Rotating Rings
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- .NET 软件分层商业项目实战
- 中文分词
- 异形卵
- stm32f407提取摄像头数据
- Irrlicht引擎剖析一
- TOJ:2971. Rotating Numbers
- Irrlicht引擎剖析二
- Netty4.0学习笔记系列之三:构建简单的http服务
- test
- 细说Cookie
- 三国志(单源最短路+01背包)
- 实例设计模式1《策略模式》
- TOJ:3210. Moon Mooing
- 堆 && 堆排序