#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; }
Category: NCPC 2016
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