AnupamRoy's blog

By AnupamRoy, history, 18 months ago, In English

https://codeforces.me/problemset/problem/1175/A

for avobe problem as editorial the solution is here . but it gives worng answer what is the problem in my python code

for i in range(int(input())): n,m=map(int,input().split()) p=0 while 1: if n%m==0: n/=m n=int(n) p+=1 else: r=(n%m) n-=r p+=r if n==0: break print(p)

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it

By AnupamRoy, history, 3 years ago, In English
  • Vote: I like it
  • 0
  • Vote: I do not like it

By AnupamRoy, history, 4 years ago, In English

Since left side size 1 and right side size 0 . the result should be for value '1'. that's index is 2.
the problem link https://codeforces.me/problemset/problem/1199/A

the screenshot of result

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it

By AnupamRoy, history, 4 years ago, In English

include<bits/stdc++.h>

using namespace std; int main() { int i,n,t,j,p,k; cin>>n; for(i=0;i<n;i++) { cin>>p>>k>>t; int a[t],r,s; int b[p+1]={0}; for(j=0;j<t;j++) { cin>>a[j]; b[a[j]]++; } for(j=k;j>=1;j--) { if(b[j]==0) { break; } } if(j==0) { r=2000000000; } else{ r=abs(j-k); } for(j=k;j<=p;j++) { if(b[j]==0) { break; } } if(j==(p+1)) { s=2000000000; } else{ s=abs(j-k); } if(r==s) {cout<<r<<endl; } else{ cout<<min(r,s)<<endl; }

}

}

Full text and comments »

  • Vote: I like it
  • -17
  • Vote: I do not like it