#21985: TLE了....


es811066 (ZIhan)

學校 : 國立臺灣海洋大學
編號 : 108578
來源 : [210.71.40.108]
最後登入時間 :
2023-12-05 16:29:56
e995. string again!! -- it's david | From: [36.227.72.181] | 發表日期 : 2020-08-08 10:55

#include<string>

#include<iostream>

#include<stack>

using namespace std;

int main(){

int a;

string s="1";

for(int i=2;i<50000;i++){

stack<char>str;

int u=i;

while(u!=0){

str.push(char('0'+u%10));

u=u/10;

}

while(str.empty()!=true){

s=s+str.top();

str.pop();

}

}

while(cin>>a){

a--;

cout<<s[a];

}

}

該如何優化呢?

 
ZeroJudge Forum