Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream cin("reorganizare2.in");
- ofstream cout("reorganizare2.out");
- int main()
- {
- long long n,inceput,sfarsit,put,cif,ccif;
- cin>>n;
- inceput=(n-1)*n/2+1;
- sfarsit=n*(n+1)/2;
- ///prima parte
- put=9;
- cif=1;
- while(put*cif<=inceput){
- inceput-=put*cif;
- put*=10;
- cif++;
- }
- ccif=(inceput-1)%cif+1;
- inceput=put/10+inceput/cif;
- ccif++;
- while(ccif<cif){
- inceput/=10;
- ccif++;
- }
- cout<<inceput%10<<" ";
- ///a doua parte
- put=9;
- cif=1;
- while(put*cif<=sfarsit){
- sfarsit-=put*cif;
- put*=10;
- cif++;
- }
- ccif=(sfarsit-1)%cif+1;
- sfarsit=put/10+sfarsit/cif;
- while(ccif<cif){
- sfarsit/=10;
- ccif++;
- }
- cout<<sfarsit%10;
- ///printf("%d ",sfarsit%10);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement