repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
Xi-Plus/OJ-Code
TOJ/toj 619.cpp
#include <bits/stdc++.h> using namespace std; int main() { int t, n, k, ans; cin >> t; while (t--) { cin >> n; ans = 0; while (n--) { cin >> k; ans += k; } cout << ans << endl; } }
Xi-Plus/OJ-Code
ZJ/zj a647.cpp
<reponame>Xi-Plus/OJ-Code // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); int t; cin>>t; while(t--){ long long a,b; cin>>a>>b; long long c=100000*(b-a)/a; bool m=(c>=10000||c<=-7000); if(c<0)cout<<"-"; c=abs(...
Xi-Plus/OJ-Code
TOJ/toj 220.cpp
#include<cstdio> using namespace std; int main(){ int t; scanf("%d\n",&t); while(t--){ int n; scanf("%d\n",&n); char c; int a=0,b=0,aa=0; for(int q=0;q<n;q++){ scanf("%c",&c); if(c=='W'){ a+=10+aa*5; aa=0; ...
Xi-Plus/OJ-Code
paiza-poh-ando/ando17/C++.cpp
#include <iostream> using namespace std; int main(){ int n,m; cin>>n>>m; for(int i=0;i<m;i+=n*2){ for(int j=0;j<n&&i+j<m;j++)cout<<"R"; for(int j=0;j<n&&i+n+j<m;j++)cout<<"W"; } }
Xi-Plus/OJ-Code
TOJ/toj 96-2.cpp
#include <bits/stdc++.h> using namespace std; void add(int a, int b){ cout<<a<<" + "<<b<<" = "<<a+b<<endl; } void sub(int a, int b){ cout<<a<<" - "<<b<<" = "<<a-b<<endl; } void mul(int a, int b){ cout<<a<<" * "<<b<<" = "<<a*b<<endl; } void div2(int a, int b){ cout<<a<<" / "<<b<<" = "<<a/b<<" ... "<<a%b<<endl; } ty...
Xi-Plus/OJ-Code
TZJ/tzj d042.cpp
// By KRT girl xiplus #include <iostream> #define endl '\n' using namespace std; int vn[]={1,1,4,4,2,1,1,4,4,2}; int v[][4]={ {0}, {1}, {6,2,4,8}, {1,3,9,7}, {6,4}, {5}, {6}, {1,7,9,3}, {6,8,4,2}, {1,9} }; int va[25]={0}; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); string s1,s2; va[0]=0; for...
Xi-Plus/OJ-Code
UVa/uva 10042.cpp
<filename>UVa/uva 10042.cpp #include <bits/stdc++.h> #define endl '\n' using namespace std; int sumdig(int n){ int ans=0; while(n){ ans+=n%10; n/=10; } return ans; } vector<int> plist; bool notp[46340]; int main() { ios::sync_with_stdio(false); cin.tie(0); for(int q=2; q<46340; q++){ if(!notp[q]){ plist...
Xi-Plus/OJ-Code
TOJ/toj 276.cpp
#include <iostream> using namespace std; int main(){ int t; cin>>t; while(t--){ int x,y; cin>>x>>y; bool ans=0; if(x>0&&x%2&&y<=x+1&&y>=1-x)ans=1; else if(x<0&&x%2==0&&y>=x&&y<=-x)ans=1; else if(y>0&&y%2==0&&x<=y-1&&x>=-y)ans=1; else if(y<=0&&y%2==0&&x...
Xi-Plus/OJ-Code
UVa/uva 699.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; struct Node{ int parent,left,right,value; }; vector<Node>node; //vector<int>ans; int ans[200]; int leftd; void dfs(int index,int d){ int td=d+leftd; // if(ans.size()<td+1)ans.resize(td+1); ans[td]+=node[index].value; if(node[in...
Xi-Plus/OJ-Code
TOJ/toj 53.cpp
<filename>TOJ/toj 53.cpp // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); string s; while(getline(cin,s)){ int ans=0; int a; stringstream t; t<<s; while(t>>a)ans+=a; co...
Xi-Plus/OJ-Code
UVa/uva 10170.cpp
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long s, d; while(cin>>s>>d){ long long sum=0; for(int p=s;; p++){ sum+=p; if(sum>=d){ cout<<p<<endl; break; } } } }
Xi-Plus/OJ-Code
ZJ/zj a013.cpp
<reponame>Xi-Plus/OJ-Code<filename>ZJ/zj a013.cpp<gh_stars>0 #include <bits/stdc++.h> using namespace std; int roman2int(char c){ switch(c){ case 'I':return 1; case 'V':return 5; case 'X':return 10; case 'L':return 50; case 'C':return 100; case 'D':return 500; case 'M':return 1000; } return 0; } int ma...
Xi-Plus/OJ-Code
UVa/uva 796.cpp
<reponame>Xi-Plus/OJ-Code // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; struct Node{ int visit,low; vector<int> son; }node[110]; struct Ans{ int a,b; }; bool cmp(Ans a,Ans b){ if(a.a==b.a)return a.b<b.b; return a.a<b.a; } vector<Ans> ans; void dfs(int i,int p,int d){ node[i...
Xi-Plus/OJ-Code
TOJ/toj 230.cpp
<gh_stars>0 // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; struct Order{ int x,y,dis; }; bool cmp(Order a,Order b){ return a.dis<b.dis; } vector<Order> disorder; int R,C; int x,y; bool v[510][510]; bool checkn(int n,int max){ if(n>0&&n<=max)return true; return fals...
Xi-Plus/OJ-Code
TOJ/toj 626.cpp
<reponame>Xi-Plus/OJ-Code<filename>TOJ/toj 626.cpp #include <bits/stdc++.h> using namespace std; int main() { int n, a; cin >> n; vector<int> v; for (int i = 0; i < n; i++) { cin >> a; v.push_back(a); } sort(v.begin(), v.end()); for (int i = 0; i < n / 2; i++) { cout << v[n - 1 - i] << " " << v[i]; if (i...
Xi-Plus/OJ-Code
ZJ/zj a450.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); int n,q; cin>>n>>q; vector<int> v; int t; while(n--){ cin>>t; v.push_back(t); } sort(v.begin(),v.end()); int a,b; while(q--){ cin>>a>>b; int ans=upper_bound(v...
Xi-Plus/OJ-Code
UVa/uva 11747.cpp
#include <bits/stdc++.h> #define endl '\n' using namespace std; int leader[1005]; int getlea(int q){ if(leader[q]==q){ return q; } return leader[q]=getlea(leader[q]); } bool same(int a, int b){ return getlea(a)==getlea(b); } void merge(int a, int b){ leader[getlea(b)]=getlea(a); } struct Edge{ int a, b, w; }; E...
Xi-Plus/OJ-Code
TOJ/toj 620.cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, k, a, b = -1; cin >> n >> k; if (k >= n) { cout << "YES" << endl; return 0; } for (int i = 0; i < k; i++) { cin >> a; } cin >> b; if (a == b) { cout << "NO" << endl; } else { cout << "YES" << endl; } }
Xi-Plus/OJ-Code
TOJ/toj 95.cpp
#include <iostream> using namespace std; int main(){ int a,b; while(cin>>a>>b)cout<<(b>=a+7?"PASS!":"FAIL! You see see you!")<<endl; }
Xi-Plus/OJ-Code
TOJ/toj 102-2.cpp
#include <bits/stdc++.h> using namespace std; double add(double a, double b){ return a+b; } double sub(double a, double b){ return a-b; } double mul(double a, double b){ return a*b; } double div(double a, double b){ return a/b; } typedef double (*ScriptFunction)(double, double); int main(){ map<char, ScriptFunct...
Xi-Plus/OJ-Code
TOJ/toj 89.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int v[500010][2]; int findleader(int a){ if(v[a][0]==a)return v[a][0]; return v[a][0]=findleader(v[a][0]); } bool setfriends(int a,int b){ int A=findleader(a),B=findleader(b); if(v[A][0]==v[B][0])return false; if(v...
Xi-Plus/OJ-Code
TOJ/toj 318.cpp
<reponame>Xi-Plus/OJ-Code<filename>TOJ/toj 318.cpp #include <bits/stdc++.h> #define endl '\n' using namespace std; double doublemod(double a,double b){ return a-(int)(a/b)*b; } double get_w(double w,double x){ // cout<<"get_w "<<w<<" "<<x<<" "<<abs(w/2-doublemod(x,w))<<endl; return abs(w/2-doublemod(x,w)); }...
Xi-Plus/OJ-Code
TOJ/toj 249.cpp
<reponame>Xi-Plus/OJ-Code // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' #define int long long using namespace std; main(){ ios::sync_with_stdio(false); cin.tie(0); int n,k; cin>>n; k=1; // cin>>k; int old[n+1],v[n+1+k]; for(int q=1;q<=n;q++){ cin>>v[q]; ...
Xi-Plus/OJ-Code
UVa/uva 111.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int n; int v[21]; int LIS(){ vector<int> lis; lis.push_back(v[1]); for(int q=2;q<=n;q++){ if(v[q]>lis.back()){ lis.push_back(v[q]); }else { lis[lower_bound(lis.begin(),lis.end(),v[q])-lis.begin()]=v[q]; } } return lis...
Xi-Plus/OJ-Code
TOJ/toj 263.cpp
// By KRT girl xiplus #include <iostream> #define endl '\n' using namespace std; const int INF=1e9; struct Treap{ Treap *l,*r; int key,sz,add,maxi; bool reverse; Treap(int k){ l=r=NULL; key=maxi=k; sz=1; add=0; } void down(){ if(add){ key+=add; if(l)l->add+=add; if(r)r->add+=add; add=0; } ...
Xi-Plus/OJ-Code
ZJ/zj a291.cpp
<reponame>Xi-Plus/OJ-Code<gh_stars>0 // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); int ans[4],query[4]; int anscnt[10],quecnt[10]; int k,t; while(cin>>ans[0]>>ans[1]>>ans[2]>>ans[3]){ memset(anscnt,0,sizeof(anscnt))...
Xi-Plus/OJ-Code
ZJ/zj d561.cpp
<filename>ZJ/zj d561.cpp // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); string s; while(cin>>s){ int i=0,sz=s.size(); double n=0; if(s[0]=='-'){ i++; } for(;s[i]!='.'&&i<sz;i++){ n*=10; n+=s[i]-'0'; ...
Xi-Plus/OJ-Code
UVa/uva 725.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; vector<int> get_each_dig(int n){ vector<int> v; v.push_back(n/10000);n%=10000; v.push_back(n/1000);n%=1000; v.push_back(n/100);n%=100; v.push_back(n/10);n%=10; v.push_back(n); return v; } bool check_vaild(vector<int>a,vector<in...
Xi-Plus/OJ-Code
UVa/uva 11150.cpp
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; while(cin>>n){ int ans=n; int n2=n+1; while(n2>=3){ ans+=n2/3; n2=n2/3+n2%3; } int ans2=n; n2=n+2; while(n2>=3){ ans2+=n2/3; n2=n2/3+n2%3; } if(n2==2){ cout<<...
Xi-Plus/OJ-Code
UVa/uva 1594.cpp
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int T, n, a, arr[20]; cin>>T; while(T--){ cin>>n; for(int q=0; q<n; q++){ cin>>arr[q]; } bool zero=false; for(int q=0; q<1005; q++){ a=arr[0]; bool allzero=true; for(int w=0; ...
Xi-Plus/OJ-Code
paiza-poh-enkoi/enkoi-1.cpp
#include <iostream> using namespace std; int main(void) { int n, t, ans = 0; cin >> n; while (n--) { cin >> t; ans += t; } cout << ans << endl; return 0; }
Xi-Plus/OJ-Code
UVa/uva 10050.cpp
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t, day, p, pa[105]; cin>>t; while(t--){ cin>>day; cin>>p; for(int q=0; q<p; q++){ cin>>pa[q]; } int ans=0; for(int d=1; d<=day; d++){ if(d%7==6||d%7==0){ continue; } ...
Xi-Plus/OJ-Code
UVa/uva 846.cpp
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int T, x, y; long long arr[47000]={0}; for(long long i=1; i<47000; i++){ if(i&1){ arr[i]=(1+i/2)*(i/2)+i/2+1; }else{ arr[i]=(1+i/2)*(i/2); } } cin>>T; while(T--){ cin>>x>>y; cout...
Xi-Plus/OJ-Code
TOJ/toj 102.cpp
<filename>TOJ/toj 102.cpp #include <iomanip> #include <iostream> using namespace std; int main(){ double a,b; char c; cin>>a>>c>>b; cout<<fixed<<setprecision(4); switch(c){ case '+': cout<<a<<" + "<<b<<" = "<<a+b<<endl; break; case '-': cout<<a<<" ...
Xi-Plus/OJ-Code
UVa/uva 1583.cpp
<reponame>Xi-Plus/OJ-Code<filename>UVa/uva 1583.cpp #include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t, n, n3, sum; cin>>t; while(t--){ cin>>n; int ans=n; for(int n2=n-1; n2>=max(n-45, 0); n2--){ sum=n3=n2; while(n3){ sum+=n3%...
Xi-Plus/OJ-Code
TOJ/toj 144.cpp
<filename>TOJ/toj 144.cpp #include <cstdio> #include <cstring> #include <iostream> using namespace std; struct V{ int a; int b; bool x; }; int main(){ int n,m; scanf("%d%d",&n,&m); V v1[m],v2[m]; for(int q=0;q<m;q++){ scanf("%d%d",&v1[q].a,&v1[q].b); v1[q].x=0; v2[q]....
Xi-Plus/OJ-Code
TOJ/toj 120.cpp
#include <iostream> using namespace std; int main(){ int n; cin>>n; long long int a[n+1]; a[0]=0; int k; for(int q=1;q<=n;q++){ cin>>k; a[q]=a[q-1]+k; } cin>>n; while(n--){ int j,k; cin>>j>>k; if(j>k)j^=k^=j^=k; cout<<a[k]-a[j-1]<<endl;...
Xi-Plus/OJ-Code
TOJ/toj 39.cpp
#include <cstdlib> #include <iostream> using namespace std; int main(){ string s; long long int n=1; while(cin>>s){ if(s=="%"){ cout<<n<<endl; n=1; } else { n*=atoi(s.c_str()); n%=479001599; } } }
Xi-Plus/OJ-Code
TOJ/toj 307.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); string a,b,ans=" "; getline(cin,a); getline(cin,b); int v[256]={0}; int sz=b.size(); for(int q=0;q<sz;q++){ v[b[q]]++; } sz=a.siz...
Xi-Plus/OJ-Code
POJ/poj 3468.cpp
<gh_stars>0 // By KRT girl xiplus #include <iostream> #define endl '\n' using namespace std; int n; struct T{ long long sum; long long lazy; }v[400000]; void init(int p,int l,int r){ v[p].sum=0; if(l==r) return; int mid=(l+r)/2; init(p*2,l,mid); init(p*2+1,mid+1,r); } void up(int id){ v[id].sum=v[id*2].sum+v[id...
Xi-Plus/OJ-Code
UVa/uva 11369.cpp
<gh_stars>0 #include <bits/stdc++.h> #define endl '\n' using namespace std; int v[20005]; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin>>t; while(t--) { int n; cin>>n; for(int q=0; q<n; q++) { cin>>v[q]; } sort(v, v+n); long long sum=0; for(int q=n-3; q>=0; q-=3) { sum += v[q...
Xi-Plus/OJ-Code
UVa/uva 10530.cpp
<reponame>Xi-Plus/OJ-Code<gh_stars>0 #include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; string s1, s2; int a=1, b=10; while(cin>>n, n){ cin>>s1>>s2; if(s1[0]=='t'){ if(s2[0]=='h'){ b=min(b, n-1); }else{ a=max(a, n+1); }...
Xi-Plus/OJ-Code
TOJ/toj 551-2.cpp
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { // ios::sync_with_stdio(false); // cin.tie(0); long long t, n, k; cin>>t; while(t--){ cin>>n>>k; while(true){ while(n%6==0)n/=6; if(n==1)break; if(k==0)break; k--; n*=2; } if(n==1){ cout<<"Yes"<<endl; }else{ c...
Xi-Plus/OJ-Code
TOJ/toj 184.cpp
<gh_stars>0 #include <iostream> #include <cstring> using namespace std; int main(){ string a, b; int la, lb; bool m1, m2; while (cin >> a >> b){ la = a.size(); lb = b.size(); m1 = (a[0] == '-'); m2 = (b[0] == '-'); if (a == "0" || b == "0")cout << "0"; els...
Xi-Plus/OJ-Code
TOJ/toj 134.cpp
<filename>TOJ/toj 134.cpp #include <iostream> #include <cstdio> #include <vector> using namespace std; vector<int>Fib[100000]; const int Max=500; vector<int>::iterator j,k,out; int main(){ Fib[0].push_back(0); Fib[1].push_back(1); for(int i=2;i<=Max;++i){ int carry=0,sum; ...
Xi-Plus/OJ-Code
TIOJ/tioj 1233.cpp
<reponame>Xi-Plus/OJ-Code // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; bool v[520][520]={0}; void dfs(int x,int y){ v[x][y]=0; if(v[x-1][y-1]) dfs(x-1,y-1); if(v[x-1][y]) dfs(x-1,y); if(v[x-1][y+1]) dfs(x-1,y+1); if(v[x][y-1]) dfs(x,y-1); if(v[x][y+1]) dfs(x,y+1); if(v[x+...
Xi-Plus/OJ-Code
TOJ/toj 133.cpp
<gh_stars>0 #include<iostream> using namespace std; int main() { int n; cin>>n; long long int q[n+1]; q[0]=0; for(int i=1;i<=n;i++){ cin>>q[i]; q[i]=q[i]+q[i-1]; } int a,b; cin>>n; while(n--){ cin>>a>>b; if(a>b)a^=b^=a^=b; cout<<q[b]-q[a-1]<<e...
Xi-Plus/OJ-Code
UVa/uva 10193.cpp
<gh_stars>0 #include <bits/stdc++.h> #define endl '\n' using namespace std; int s2n(string s){ int ans=0; for(int q=0; q<s.size(); q++){ ans*=2; ans+=s[q]-'0'; } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(0); int T, n1, n2; cin>>T; string s1, s2; for(int t=1; t<=T; t++){ cin>>s1>>s2...
Xi-Plus/OJ-Code
paiza-poh-enkoi/enkoi-2.cpp
#include <iostream> using namespace std; int main(void) { int n, ans = 0, t, s, p; cin >> n; while (n--) { cin >> t >> s >> p; if (t > s) { ans += (t - s) * p; } } cout << ans << endl; return 0; }
Xi-Plus/OJ-Code
UVa/uva 11462.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); int n; while(cin>>n,n){ int t; vector<int> v; for(int q=0;q<n;q++){ cin>>t; v.push_back(t); } sort(v.begin(),v.end()); cout<<v[0]; for(int q=1;q<n;q++)co...
Xi-Plus/OJ-Code
TOJ/toj 470.cpp
#include <bits/stdc++.h> #define endl '\n' using namespace std; int dp[1000005][2]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, c; while(cin>>n){ dp[0][0]=0; dp[0][1]=0; cin>>c; dp[1][0]=c; dp[1][1]=0; for(int q=2; q<=n; q++){ cin>>c; dp[q][0] = max(max(dp[q-2][0],dp[q-2][1]),dp[q...
Xi-Plus/OJ-Code
UVa/uva 12385.cpp
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t, n, k, l, ans, last[100005]; cin>>t; while(t--){ cin>>n; memset(last, 0, sizeof(last)); l=0; ans=0; for(int q=1; q<=n; q++){ cin>>k; if(last[k]>=l&&last[k]!=0){ ans++; ...
Xi-Plus/OJ-Code
CF/cf 319B.cpp
// By xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); int n,t,ans=0; vector<int> v1,v2; cin>>n; for(int q=0;q<n;q++){ cin>>t; v1.push_back(t); } bool v=1; while(true){ if(v){ v2.clear(); v2.push_back(v1[0]); int sz=v...
Xi-Plus/OJ-Code
UVa/uva 299.cpp
#include <bits/stdc++.h> #define endl '\n' using namespace std; int bit[55]; int arr[55]; int l; void add(int x, int v) { while (x <= l) { bit[x] += v; x += (x&(-x)); } } int get(int x) { int ans = 0; while (x > 0) { ans += bit[x]; x -= (x&(-x)); } return ans; } int main() { ios::sync_with_stdio(false); ...
Xi-Plus/OJ-Code
TIOJ/tioj 1061.cpp
<reponame>Xi-Plus/OJ-Code #include <cstdio> #include <cstring> #include <set> #include <algorithm> using namespace std; int sta[10], p; int ch (char c) { switch (c) { case 'O': return 0; case 'X': return 1; case '-': return 2; } }int AC[3];//O ?A??X ?A?????? set <int> s; bool in () { int t=0, i; for (i = 0...
Xi-Plus/OJ-Code
UVa/uva 318/uva 318.cpp
<reponame>Xi-Plus/OJ-Code<filename>UVa/uva 318/uva 318.cpp // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; struct Side{ int to; long long cost; }; struct Line{ int a,b; long long w; }; struct Node{ long long cost; vector<Side> side; }; struct NodeDis{ int p; long long cost;...
Xi-Plus/OJ-Code
TOJ/toj 162.cpp
#include<iostream> using namespace std; int main(){ int t; cin>>t; string s1,s2; int v[3][3]; while(t--){ cin.get(); getline(cin,s2); getline(cin,s1); for(int q=0;q<3;q++)for(int w=0;w<3;w++)cin>>v[q][w]; int a=0,b=0; if(v[0][0]==0&&v[0][1]==0&&v[0...
Xi-Plus/OJ-Code
UVa/uva 10101.cpp
<filename>UVa/uva 10101.cpp<gh_stars>0 #include <bits/stdc++.h> #define endl '\n' using namespace std; void trans(long long n){ if(n>=10000000){ trans(n/10000000); } long long n2=n; if(n>=10000000){ cout<<" kuti"; } n2%=10000000; if(n2/100000){ cout<<" "<<n2/100000<<" lakh"; n2%=100000; } if(n2/1000){ ...
Xi-Plus/OJ-Code
TOJ/toj 228.cpp
<filename>TOJ/toj 228.cpp // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int F[1003][2]; int main(){ ios::sync_with_stdio(false); cin.tie(0); int t,r,s; char c; cin>>t; while(t--){ cin>>r>>s; int ans=0; for(int q=r;q>=1;q--){ ...
Xi-Plus/OJ-Code
UVa/uva 10922.cpp
<filename>UVa/uva 10922.cpp #include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string s; int n, n2, d; while(cin>>s, s!="0"){ n=0; for(int q=0; q<s.size(); q++){ n+=s[q]-'0'; } d=1; while(n>9){ n2=0; while(n){ n2+=n%10; n...
Xi-Plus/OJ-Code
UVa/uva 948.cpp
<gh_stars>0 #include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); vector<int> fib; fib.push_back(1); fib.push_back(1); for(int q=1; fib[q]<100000000; q++) { fib.push_back(fib[q-1]+fib[q]); } int t, n; cin>>t; while(t--){ cin>>n; cout<<n<<" ...
Xi-Plus/OJ-Code
TOJ/toj 3.cpp
<reponame>Xi-Plus/OJ-Code<filename>TOJ/toj 3.cpp #include <iostream> using namespace std; int main(){ long long int a,b; int n; cin>>n; while(n--){ cin>>a>>b; while((a%=b)&&(b%=a)); cout<<a+b<<endl; } }
Xi-Plus/OJ-Code
TOJ/toj 97.cpp
#include <iostream> using namespace std; int main(){ bool a,b; cin>>a>>b; if(a||b)cout<<"BUG FREE!"<<endl; else cout<<"BARRIER BREACHED!"<<endl; }
Xi-Plus/OJ-Code
CF/cf 987B-2.cpp
#include<bits/stdc++.h> using namespace std; int main(){ int x,y; cin>>x>>y; long double a=x*log(y); long double b=y*log(x); if(abs(a-b)<1e-6){ cout<<"="<<endl; }else if(a>b){ cout<<"<"<<endl; }else{ cout<<">"<<endl; } }
Xi-Plus/OJ-Code
TOJ/toj 119.cpp
<gh_stars>0 #include <cmath> #include <iostream> using namespace std; int main(){ int n,t,a,b,k; int v[200005]; while(cin>>n){ for(int q=1;q<=n;q++)cin>>v[q]; cin>>t; bool x=1; for(int q=1;q<=t;q++){ cin>>a>>b; if(abs(a-b)>8)x=0; if(x){ ...
Xi-Plus/OJ-Code
UVa/uva 112.cpp
<reponame>Xi-Plus/OJ-Code // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; struct Node{ int parent,left,right,sum,parentsum; bool isleaf; }; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); int n; char c; while(cin>>n){ bool x=0; vector<Node>node; node.push_b...
Xi-Plus/OJ-Code
UVa/uva 536.cpp
<gh_stars>0 // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; string pre,in; int used,p; struct Node{ int parent,left,right; char c; }; vector<Node>node; void create(int l,int r,int lastnode,bool side){ int mid=-1; for(int q=l;q<=r;q++){ if(in[q]==pre[p]){ mid=q; break; ...
Xi-Plus/OJ-Code
TOJ/toj 138.cpp
<reponame>Xi-Plus/OJ-Code #include<iostream> using namespace std; int main() { long long int k,x; while(cin>>k){ if(k>10000||k<=0)while(1); long long int v[1000][2]; int n=0; for(long long int y=k+1;true;y++){ x=(k*y)/(y-k); if((k*y)%(y-k)==0){ ...
Xi-Plus/OJ-Code
UVa/uva 10048.cpp
<gh_stars>0 // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; struct Side{ int p,w; }; struct Point{ int w; vector<Side> side; }point[110]; void dfs(int now){ for(auto i:point[now].side){ if(point[i.p].w>max(point[now].w,i.w)){ point[i.p].w=max(point[now].w,i.w); dfs(i.p)...
Xi-Plus/OJ-Code
TIOJ/tioj 1603.cpp
<filename>TIOJ/tioj 1603.cpp // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int n; struct T{ int l,r; long long minn,maxn; }v[400000]; void init(int p,int l,int r){ v[p].l=l; v[p].r=r; v[p].minn=1e18; v[p].maxn=0; if(l==r) return ; int mid=(l+r)/2; init(p*2,l,mid); init(...
Xi-Plus/OJ-Code
UVa/uva 1262.cpp
<filename>UVa/uva 1262.cpp #include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t, k; char c; cin>>t; while(t--){ cin>>k; set<char> can1[5]; for(int q=0; q<6; q++){ for(int w=0; w<5; w++){ cin>>c; can1[w].insert(c); } } s...
Xi-Plus/OJ-Code
UVa/uva 10098.cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; while(n--){ char s[11]; scanf("%s", s); int sz = strlen(s); sort(s, s+sz); do { cout<<s<<endl; } while(next_permutation(s, s+sz)); cout<<endl; } }
Xi-Plus/OJ-Code
TOJ/toj 127.cpp
#include <iostream> using namespace std; int main(){ int n; string s; cin>>n>>s; for(int q=0;q<s.size();q++){ if(s[q]-n<'A')cout<<(char)(s[q]-n+26); else cout<<(char)(s[q]-n); } cout<<endl; }
Xi-Plus/OJ-Code
TOJ/toj 218.cpp
<gh_stars>0 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> using namespace std; bool bp[1000002]={false}; int p[100000]; int main(){ int k=2; bp[2]=false; bp[3]=false; p[1]=2; p[2]=3; int l; for(int q=4;q<1000000;q++){ l=sqrt(q); for(int w=1;w<=k&&p[w]<...
Xi-Plus/OJ-Code
UVa/uva 10093.cpp
<filename>UVa/uva 10093.cpp #include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string chars=""; map<char, int> cidx; for(int q=0; q<10; q++){ chars+=(char)('0'+q); cidx['0'+q]=q; } for(int q=0; q<26; q++){ chars+=(char)('A'+q); cidx['A'+q...
Xi-Plus/OJ-Code
UVa/uva 10062.cpp
<filename>UVa/uva 10062.cpp<gh_stars>0 #include <bits/stdc++.h> #define endl '\n' using namespace std; bool cmp(pair<char, int>a, pair<char, int>b){ if(a.second==b.second){ return a.first>b.first; } return a.second<b.second; } int main() { ios::sync_with_stdio(false); cin.tie(0); string s; bool first=false; w...
Xi-Plus/OJ-Code
ZJ/zj a517.cpp
<filename>ZJ/zj a517.cpp<gh_stars>0 // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; typedef unsigned long long ULL; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); unsigned long long v[3],m,n; while(cin>>v[0]>>v[1]>>v[2]){ sort(v,v+3); m=sqrt(v[1]-v[0]); n=sqrt(v...
Xi-Plus/OJ-Code
UVa/uva 369.cpp
<reponame>Xi-Plus/OJ-Code #include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, m, mm; while(cin>>n>>m, n) { mm = m; if(m*2 > n) m = n-m; long long ans = 1; for(int q=1; q<=m; q++) { ans *= n-q+1; ans /= q; } cout<<n<<" t...
Xi-Plus/OJ-Code
UVa/uva 10071.cpp
<filename>UVa/uva 10071.cpp<gh_stars>0 #include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int v, t; while(cin>>v>>t){ cout<<2*v*t<<endl; } }
Xi-Plus/OJ-Code
TOJ/toj 325.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; bool dp[1002010]; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); int n; cin>>n; memset(dp,0,sizeof(dp)); dp[0]=1; int t; int sum=0; for(int q=1;q<=n;q++){ cin>>t; sum+=t; for(int w=min(2000*q,1000000);w>=0;w--...
Xi-Plus/OJ-Code
TOJ/toj 124.cpp
<reponame>Xi-Plus/OJ-Code<gh_stars>0 //#include <cstdio> //c¿é¤J¿é¥X //#include <fstream> //#include <sstream> //cmd //#include <conio.h> //if(kbhit()) //#include <windows.h> //#include <ctime> //time srand(time(NULL)); //#include <algorithm> //sort(n,n+k) reverse //#include <iomanip> //¤p¼Æ fixed<<setprecision or ...
Xi-Plus/OJ-Code
TOJ/toj 596.cpp
<reponame>Xi-Plus/OJ-Code #include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; for (int i = 5, j = 7; i <= a || j <= b; i += 5, j += 7) { cout << i << " " << j << endl; } }
Xi-Plus/OJ-Code
LeetCode/leetcode 1399.cpp
#include <bits/stdc++.h> using namespace std; class Solution { public: int countLargestGroup(int n) { map<int, int> count; int t, sum; for (int i = 1; i <= n; i++) { t = i; sum = 0; while (t) { sum += t % 10; t /= 10; } count[sum]++; } int groupcnt = 0, maxcount = 0; for (auto v ...
Xi-Plus/OJ-Code
TOJ/toj 168.cpp
<filename>TOJ/toj 168.cpp #include <iostream> using namespace std; int main(){ int n; while(cin>>n){ int v[n]; for(int q=n-1;q>=0;q--)cin>>v[q]; int p=-1,ans=0; for(int q=0;q<n;q++){ if(v[q]>p){ p=v[q]; ans++; } } ...
Xi-Plus/OJ-Code
TOJ/toj 110.cpp
#include <iostream> using namespace std; int main(){ int n,k; cin>>n; while(n--){ cin>>k; for(int q=1;q<=k-3;q++){ for(int w=1;w<=k-q;w++)cout<<" "; for(int w=1;w<=q*2-1;w++)cout<<"*"; cout<<endl; } for(int q=1;q<=k*2-1;q++)cout<<"*"; ...
Xi-Plus/OJ-Code
ZJ/zj a760.cpp
<reponame>Xi-Plus/OJ-Code // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); string s; while(getline(cin,s)){ string a=""; int n=0; for(int q=0;q<s.size();q++){ if((s[q]<='Z'&&s[q]>='A')||(s[q]<='z'&&s[q]>='a')){ ...
Xi-Plus/OJ-Code
TOJ/toj 100.cpp
<reponame>Xi-Plus/OJ-Code #include <iostream> using namespace std; int main(){ char c; cin>>c; if(c=='A')cout<<"@"<<endl; else cout<<(char)(c-1)<<endl; }
Xi-Plus/OJ-Code
TIOJ/tioj 1005.cpp
<gh_stars>0 // By KRT girl xiplus #include <bits/stdc++.h> using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); int n,a,b,c; while(cin>>n,n){ int v[n]; for(int q=0;q<n;q++)cin>>v[q]; c=0; for(int q=0;q<n-1;q++){ for(int w=q+1;w<n;w++){ a=v[q]; b=v[w]; while((a%=b)&...
Xi-Plus/OJ-Code
UVa/uva 10242.cpp
<reponame>Xi-Plus/OJ-Code #include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); double x[4], y[4]; cout<<fixed<<setprecision(3); while(cin>>x[0]>>y[0]){ for(int q=1; q<4; q++){ cin>>x[q]>>y[q]; } bool c=false; for(int q=0; q<2; q++){ for...
Xi-Plus/OJ-Code
UVa/uva 10929.cpp
<gh_stars>0 #include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string s; while(cin>>s, s!="0"){ int a=0, b=0; for(int q=0; q<s.size(); q++){ if(q&1) { a+=s[q]-'0'; } else { b+=s[q]-'0'; } } if((a-b)%11==0){ cout<<s<<" is ...
Xi-Plus/OJ-Code
TIOJ/tioj 1234.cpp
<reponame>Xi-Plus/OJ-Code // By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int gcd(int a,int b){ while((a%=b)&&(b%=a)); return a+b; } struct num{ int a,b; double c; }; bool cmp(num a,num b){ return a.c<b.c; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin>>...
Xi-Plus/OJ-Code
TOJ/toj 111.cpp
<reponame>Xi-Plus/OJ-Code #include <iostream> using namespace std; int main(){ long long a=2; int b,c; cin>>b>>c; while(a%b){ a=a*2+1; } if(a%c)cout<<"left"<<endl; else cout<<"right"<<endl; }
Xi-Plus/OJ-Code
ZJ/zj d713.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); priority_queue<long long> v1; priority_queue<long long,vector<int>,greater<int>> v2; int n; bool count=0; while(cin>>n){ count^=1; if(v2.size()>v1.size()){ int t=v...
Xi-Plus/OJ-Code
TOJ/toj 123.cpp
#include <iostream> using namespace std; int main() { int n; cin >> n; int a[2][n]; char c; for (int q = 0; q < n; q++) { cin >> c; a[0][q] = c - '0'; } for (int q = 0; q < n; q++) { cin >> c; a[1][q] = c - '0'; } bool failed = false; for (int q = 0; q < n - 1; q++) { if (a[0][q] + a[0][q + 1] == 2)...
Xi-Plus/OJ-Code
UVa/uva 612.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; struct T{ int idx; string s; int bit; }; bool cmp(T a,T b){ if(a.bit==b.bit)return a.idx<b.idx; return a.bit<b.bit; } int main(){ // ios::sync_with_stdio(false); // cin.tie(0); int t; cin>>t; while(t--){ int n,m; cin>>n>>m...
Xi-Plus/OJ-Code
TOJ/toj 313.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int v[10010][10010]; int main(){ ios::sync_with_stdio(false); cin.tie(0); int t,r,l,x,m; cin>>t; while(t--){ cin>>r>>l>>x>>m; for(int q=1;q<=r;q++)v[1][q]=1; for(int q=2;q<=l;q+=2){ ...
Xi-Plus/OJ-Code
ZJ/zj d140.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); cout<<fixed<<setprecision(2); string s; while(cin>>s){ stringstream ss(s); long long n,d; char c; ss>>n>>c>>d; n=n*100+d; if(n<=100*100)n=n*9+8*1000; else if(...
Xi-Plus/OJ-Code
UVa/uva 727.cpp
// By KRT girl xiplus #include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ // ios::sync_with_stdio(false); // cin.tie(0); int t; cin>>t; cin.ignore(); cin.ignore(); string s; char c; map<char,int> pri; pri['(']=3; pri['*']=2; pri['/']=2; pri['+']=1; pri['-']=1; while(t--){ stack<ch...
Xi-Plus/OJ-Code
POJ/poj 2431.cpp
#include <iostream> #include <algorithm> #include <queue> #define endl '\n' using namespace std; pair<int,int> stop[10005]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin>>n; int a, b; for(int q=0; q<n; q++) { cin>>stop[q].first>>stop[q].second; } stop[n] = {0, 0}; sort(stop, stop+n+1); in...
Xi-Plus/OJ-Code
TIOJ/tioj 1885.cpp
<gh_stars>0 // By KRT girl xiplus #include <bits/stdc++.h> //#include "lib1885.h" #define endl '\n' using namespace std; int getMinVal(tuple<pair<int,int>,pair<int,int>,pair<int,int>>q){ return min(min(get<0>(q).second,get<1>(q).second),get<2>(q).second); } int getMaxVal(tuple<pair<int,int>,pair<int,int>,pair<int,int>...