poj 1019
来源:互联网 发布:方天画戟淘宝 编辑:程序博客网 时间:2024/05/23 19:17
模拟实现:
/*288k 0ms*/
#include <iostream>#include <fstream>using namespace std;/*模拟算法*/int Getlen(int a);int Getvalue(int a,int k);int main(){ int t; cin>>t; while(t--) { int a; cin>>a; int cur=1; int cursize=1; while(a-cursize>=0) { cur++; a-=cursize; // cout<<a<<" "; cursize+=Getlen(cur); } if(a==0) { cout<<(cur-1)%10<<endl; continue; } //cur代表的是当前的数字 int s=1; int curs=1; while(a-curs>=0) { s++; a-=curs; curs=Getlen(s); } if(a==0) cout<<(s-1)%10<<endl; else { s++; cout<<Getvalue(s,a)<<endl; } } system("pause"); }int Getlen(int a){ int i=1; while(a/10) { i++; a=a/10; } return i;}int Getvalue(int a,int k){ int l=Getlen(a); int p=l-k; while(p--) { a=a/10; } return a%10;}
实验数据:
11123456789398765432182147483647221474836483214748365671923500000085000000499999150000145000000035055004500045000000500000003800
- poj 1019
- POJ-1019
- POJ 1019
- POJ 1019
- POJ 1019
- poj 1019
- POJ 1019
- poj 1019
- POJ 1019
- poj 1019
- poj-1019
- poj 1019
- poj 1019
- poj-1019
- poj 1019
- POJ 1019 Number Sequence
- POJ 1019 Number Sequence
- poj 1019 Number Sequence
- DirectX 3D_实践之DirectX3D的基本绘制流程
- 从头开始编译 PHP 5.5
- 乐观复制算法-1.介绍
- 中文分词评测方法
- 乐观复制算法-2.采用乐观复制技术的应用
- poj 1019
- rtcp rtp by rtsp open on ffmpeg
- js操作cookie
- HDU2047:阿牛的EOF牛肉串
- Cache line
- 乐观复制算法-3.基本定义 4.单Master系统
- java实训day03之基本语句,语法
- JAVA全局变量和局部变量简单介绍
- C++智能指针:auto_ptr、shared_ptr、weak_ptr等