There is a problem with online judge results for this problem. It accepts for n=6 as AC result as : 2^-6 = 1.562e-2 and for n=7 AC result as : 2^-7 = 7.812e-3 But it should be 2^-6 = 1.563e-2 and 2^-7 = 7.813e-3 respectively using approximation method after 3rd decimal. So to get AC from UVA OJ I
Author: Asif Naeem
471
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <vector> #define ll long long #define LIMIT 9876543210 using namespace std; vector<int> vb; bool isRepeated(ll num) { if(num>=0 && num<=10) return 0; bool digits[10]; memset(digits,0,sizeof(digits)); while(num) { if(digits[num%10]) return 1; digits[num%10]=1; num/=10; } return 0; } int main() { int t; ll n; ll num; for(int
460
#include <iostream> #include <cstdlib> #include <cmath> #include <cstdio> using namespace std; struct point{ int x,y; }; point LL1,LL2,LR1,LR2,UL1,UL2,UR1,UR2; point New_LL,New_LR,New_UL,New_UR; bool isOverlap() { if(LL1.x>=LR2.x) return 0; if(LR1.x<=LL2.x) return 0; if(LL1.y>=UL2.y) return 0; if(UL1.y<=LL2.y) return 0; return 1; } bool isTotalInside() { if((LL1.x>=LL2.x && LL1.x <= UR2.x) && (LL1.y>=LL2.y && LL1.y <= UR2.y)) { if((LR1.x>=LL2.x &&
107
#include <iostream> #include <cstdio> #include <cmath> #include <vector> #define ll long long #define MOD 1000000007 using namespace std; int _pow(int n,int p) { if(p==0) return 1; else return n*_pow(n,p-1); } int isAnyRoot(int a,int b) { if(a%b!=0) return -1; int cnt=0; while(a>=b) { cnt+=1; a=a/b; if(a>=b && a%b!=0) return -1; } return cnt; } int main()
278
#include <iostream> #include <cstdio> using namespace std; int main() { int t; int row,col; char ch,c; scanf("%d%c",&t,&ch); while(t–) { scanf("%c%d%d%c",&ch,&row,&col,&c); if(ch=='r') { printf("%d\n",(row<=col?row:col)); } else if(ch=='k') { //knight alwsy attacks of the other color squares, so total non attacking //knighta are = half of the area //if total square is odd, i.e. dimensions are odd
NCPC-8
#include <iostream> #include <cstdio> #include <cstring> #include <string> using namespace std; int arr[30]; int main() { char str[1010]; char ch; int t; scanf("%d",&t); while(t–) { scanf("%s",str); for(int i=0;i<strlen(str);i++) { if(arr[str[i]-'a']==0) arr[str[i]-'a']=1; else arr[0]+=1; } for(int i=0;i<=25;i++) { if(arr[i]!=0) { ch = 'a'+i; for(int j=1;j<=arr[i];j++) printf("%c",ch); arr[i]=0; } } printf("\n"); } return 0; }
NCPC-3
#include <iostream> #include <cstdio> #include <cmath> #include <vector> #define ul unsigned long long using namespace std; vector<int> vb; int gcd(int a,int b) { if(a%b==0) return b; else return gcd(b,a%b); } int main() { int kase=1; int t,increment,lim; ul n,sum=0; cin>>t; while(t–) { cin>>n; vb.clear(); lim = sqrt(n); if(n%2) increment = 2; else increment = 1;
NCPC-2
#include <iostream> #include <cstdio> using namespace std; int arr[10005]; int n; int Search(int num) { int i=1; while(i<=n) { if(arr[i]==num) return i; i++; } } /* 5 5 5 1 3 2 4 9 4 5 1 2 6 3 8 9 7 //Case 1/2: 3/6 */ int main() { int t,nxtIdx,kase=1; cin>>t; while(t–) {
NCPC-1
#include <iostream> #include <cstdio> #define ul unsigned long long using namespace std; ul twosPower[60]; ul binSearch(int Left) { int lw=0,hi=55; int mid; while(hi-lw>0) { mid = (lw+hi)/2; if(Left<twosPower[mid]) { hi=mid; } else if(Left>=twosPower[mid]) { lw=mid+1; } } return twosPower[lw-1]; } int recursion(ul Left,ul Right) { //<<"inside recur "<<Left<<" "<<Right<<endl; ul LeftNumberFloor; if(Left==0) return 0; else
11827
#include <iostream> #include <sstream> #include <cstdio> #include <cstring> #include <vector> using namespace std; vector<int> vb; int gcd(int a,int b) { if(a%b==0) return b; else return gcd(b,a%b); } int main() { int n,a; int x,y; string str; cin>>n; getchar(); stringstream iss; int mx; while(n–) { //cin>>x>>y; //cout<<gcd(x,y)<<"\n"; getline(cin,str); iss<<str; mx=0; vb.clear(); while(iss>>a) { //cout<<"sdd\n"; vb.push_back(a); }