You are not logged in. Please login at www.codechef.com to post your questions!

×

# Why is this solution wrong?(for YVNUM[December Cookoff)]

Please go through my code and let me know where I am going wrong. It gives correct output for majority numbers,but fails for some.

# include<bits stdc++.h="">

using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int T; cin>>T; while(T--) { long long int n,t,a,c=0,i; cin>>n; t=n; while(t>0) { c++; t/=10; } for(i=1;i<=c;i++) { cout<<n; a=n/pow(10,c-1); n=n%(long int)pow(10,c-1); n=n*10+a; } } }

asked 24 Dec '18, 13:03

-21
accept rate: 0%

 0 |n| is of the order 10^5. You can't store this big number in long long int. Try using a string to store the input number. answered 24 Dec '18, 13:14 36●4 accept rate: 6%
 0 |n| is of the order of 10^5 as kshitij_07 pointed out. It means $n < 10^{10^5}$ answered 24 Dec '18, 13:49 98●5 accept rate: 20%
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• link:[text](http://url.com/ "title")
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×678
×51

question asked: 24 Dec '18, 13:03

question was seen: 109 times

last updated: 24 Dec '18, 13:49