code_file1
stringlengths
80
4k
code_file2
stringlengths
91
4k
similar_or_different
int64
0
1
#include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <set> #include <iostream> #include <string> #include <vector> #include <algorithm> #include <sstream> #include <complex> #include <stack> #include <queue> #include <cstdio> #include <cstring> #include <iterator> #include <b...
#include<iostream> #include<cstdio> using namespace std; #define N 200012 int n,a[N],las=0;bool vis[N];long long ans=0; int main(){ scanf("%d",&n);int i,l,r,lef;bool fl=true; for(i=1;i<=n;i++)scanf("%d",&a[i]); for(i=1;i<=n;i=r+1) { l=r=i;while((r<n)&&(a[r+1]==(a[r]+1)))++r; lef=l-a[l];if(lef<=las){printf("-1")...
0
#include<iostream> #include<vector> #include<algorithm> using namespace std; struct edge{ int u; //????????? int v; //??°?????? int cost; //?????? //???????????????????????§?????§?°???¢???????????? bool operator<(const edge& another) const { return cost < another.cost; } }; const int MAX_N = 100000; const i...
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using vll = vector<ll> ; using vs = vector<string> ; #define all(v) v.begin(),v.end() const int MAX_V = 210; const int INF = 1e5; int V; vll G[MAX_V]; int match[MAX_V]; bool used[MAX_V]; void add_...
0
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i,s,n) for(int i=s;i<n;i++) #define MOD 1000000007 #define NUM 2520 #define INF (1LL<<50) #define DEBUG 0 #define mp(a,b) make_pair(a,b) #define SORT(V) sort(V.begin(),V.end()) #define PI (3.141592653589794) const int MAX = 510000; l...
#include <bits/stdc++.h> #define ll long long int #define MOD 1000000007 #define INF 1000000000000000000 using namespace std; ll power(ll n, ll k){ ll res = 1; while(k > 0){ if (k & 1) res = res * n % MOD; n = n * n % MOD; k >>= 1; } return res; } ll genfact(ll n, ll k){ ll res = 1; k-...
1
#include <bits/stdc++.h> #define PI 3.1415926535897932 #define _GLIBCXX_DEBUG using namespace std; long long GCD(long long A,long long B){ if(B==0){ return A; } else{ return GCD(B,A%B); } } int main() { string A,B,C; cin>>A>>B>>C; deque<char> X; for(int i=0;i<A.size();i++){ X.push_back...
#include <bits/stdc++.h> template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}} template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}} #define ll long long #define double long double #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i...
0
#include <iostream> #include <numeric> #include <stdio.h> #include <iomanip> #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cst...
// http://algorithms.blog55.fc2.com/blog-entry-66.html #include <iostream> using namespace std; #include <stdio.h> #include <string.h> #define M 100 int N,R[M+1],C[M][M],B[M][M]; void compute(){ int i=0,j,k,cost; memset(C,99,sizeof(C)); for(;i<N;i++)C[i][i]=0; for(j=1;j<N;j++) for(i=0;i<N - j; i++ ) for (k...
0
#include <bits/stdc++.h> using namespace std; int main() { int num; int tmpCnt1,tmpCnt2; int Max1 = 0, Max2 = 0; string str1, str2; cin >> num >> str1 >> str2; if(str1 == str2){ cout << num; return 0; } for(int i = 0; i < num; i++){ tmpCnt1 = 0; if(str1.at(i) == str2.at(0)){ ...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i< (n); i++) using ll = long long; using namespace std; int main(void){ int N; string s, t; cin >> N >> s >> t; int ans = 2*N; rep(i,N) { if (s.substr(i,N-i) == t.substr(0,N-i) ){ ans = N+i; break;} ...
1
#include<iostream> #include<algorithm> using namespace std; int n,m,a[1000]; main() { while(cin>>n>>m,n) { int ans=0; for(int i=0;i<n;i++) { cin>>a[i]; ans+=a[i]; } sort(a,a+n); for(int i=n-m;i>=0;i-=m) { ans-=a[i]; } cout<<ans<<endl; } }
#include<iostream> using namespace std; int main(){ int n,m; while(1){ int ans=0,p[10001]={}; cin>>n>>m; if(n+m==0)break; for(int i=1;i<=n;i++){ cin>>p[i]; } for(int j=0;j<n;j++) for(int i=1;i<=n;i++) if(p[i]<p[i+1])swap(p[i],p[i+1]); for(int i=1;i<=n;i++){ if(i%m==0)p[i]=0; ...
1
#include <bits/stdc++.h> using namespace std; int func(int x){ string y=to_string(x); vector<char> a(y.size()); vector<char> b(y.size()); for(int i=0;i<y.size();i++){ a.at(i)=y.at(i); b.at(i)=y.at(i); } reverse(b.begin(),b.end()); int c=0; for(int i=0;i<y.size();i++){ if(a.at(i)!=b.at(i)) ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int r = 0; for (int i = a; i <= b; i++) { int s = i % 10; int t = i / 10000 % 10; int u = i / 10 % 10; int v = i / 1000 % 10; if (s == t && u == v) { r++; ...
1
#include <bits/stdc++.h> // #include "ane.cpp" const int INF = 1e9; const long long INFLL = 1e18; const int NMAX = 100005; const int MMAX = 100005; const int KMAX = 1005; const int MOD = 1e9 + 7; using namespace std; // comment to disable debug functions #define DEBUG // frequently used macros #if __cplusplus >= ...
#include<bits/stdc++.h> using namespace std; struct UF{ int N,par[10000],sz[10000]; void init(int _N){ N=_N; for(int i=0;i<N;i++){ par[i]=i; sz[i]=1; } } int find(int x){ return x==par[x]?x:par[x]=find(par[x]); } void unite(int x,int y)...
1
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; if(s.size()%2==1){ cout<<"No"<<endl; return 0; } for(int i=0;i<s.size();i++){ if(s.at(i)!=(i%2==0?'h':'i')){ cout<<"No"<<endl; return 0; } } cout<<"Yes"<<endl; }
#include <bits/stdc++.h> #define rep(i,l,n) for(int i=l;i<n;i++) #define rer(i,l,n) for(int i=l;i<=n;i++) #define all(a) a.begin(),a.end() #define o(a) cout<<a<<endl #define pb(a) push_back(a) #define mk(a,b) make_pair(a,b) #define fi first #define se second using namespace std; typedef long long ll; typedef vector<int...
0
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int n; struct node { int key; node *parent,*left,*right; node():key(-1),parent(NULL),left(NULL),right(NULL) {} }; node *root,*nil; node* newnode() { return new node(); } void insert(int num) { node* x=root; node* y=n...
#include <bits/stdc++.h> typedef long long ll; typedef long double ld; #define rep(i,n) for(ll i=0;i<(n);i++) #define repr(i,n) for(ll i=(n-1);i>=0;i--) #define all(x) x.begin(),x.end() #define br cout << "\n"; using namespace std; const long long INF = 1e10; const long long MOD = 1e9+7; using Graph = vector<vector<ll>...
0
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define MOD 1000000007 #define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++) #define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++) #define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n)...
#include <bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,b,a) for(int i=b;i>=a;i--) #define fori(a) for(auto i : a ) #define all(a) begin(a), end(a) #define set(a,b) memset(a,b,sizeof(a)) #define sz(a) a.size() #define pi 3.14159 #define ll long long #define ull unsigned long long #define pb push...
1
#include <bits/stdc++.h> #define all(vec) vec.begin(),vec.end() using namespace std; using ll=long long; using P=pair<int,int>; const ll INF=1LL<<30; const ll LINF=1LL<<61; const double eps=1e-9; const ll MOD=1000000007LL; vector<ll> f,fi; ll mpow(ll x,ll n){ ll res=1; while(n>0){ if(n&1){ r...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define i_7 (ll)(1E9+7) #define i_5 (ll)(1E9+5) ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; else return c+i_7; } typedef pair<int,int> i_i; typedef pair<ll,ll> l_l; ll inf=(ll)1E12; #define rep(i,l,r) for(ll i=l;i<=r;i++) #define pb push_ba...
1
#include<iostream> #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<n;i++) using P = pair<int,int>; /* 大文字を小文字に変換 */ char tolower(char c) {return (c + 0x20);} /* 小文字を大文字に変換 */ char toupr(char c) {return (c - 0x20);} // if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A'; /* s...
#include <bits/stdc++.h> using namespace std; int main(){ int M; cin >> M; vector<int> d(M); vector<long long> c(M); for (int i = 0; i < M; i++){ cin >> d[i] >> c[i]; } long long cnt = 0; long long sum = 0; for (int i = 0; i < M; i++){ cnt += c[i]; sum += c[i] * d[i]; } cout << cnt + (...
1
#include<bits/stdc++.h> using namespace std; #define ll long long const int N = 1e3 + 5; const ll mod = 1e9 + 7; ll mul(ll a, ll b){ return (a * b) % mod; } ll power(ll x, ll y){ if(y == 1){ return x; } else { ll tmp = power(x, y/2); if(y & 1){ return mul(mul(tmp, tmp), x); } else { return mul(tmp, t...
#include <iostream> #include <vector> #define pb push_back #define mp make_pair using namespace std; const long long INF = 2e18 + 18; vector<long long> dp, cost; vector<vector<long long> > c; void solve() { int n; cin >> n; c.resize(n, vector<long long>(n)); dp.resize((1 << n), -INF); cost.resize((1 << n)); fo...
0
#include <iostream> #include <iomanip> #include <algorithm> #include <stdio.h> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <utility> #include <tuple> #include <math.h> #include <set> #include <map> using namespace std ; using ll = long long ; using ld = long double ; ...
/** * @FileName f.cpp * @Author kanpurin * @Created 2020.08.31 16:46:32 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int h,w;cin >> h >> w; set<pair<int,int>> st1; // (現在地,スタート位置) multiset<int> st2; // 移動回数 for (int i = 0; i < w; i++) { st1.in...
1
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <cstdio> #include <cmath> #include <cstdlib> #include <cstring> #include <stack> #include <queue> #include <set> #include <bitset> #include <map> #include <unordered_map> #include <ctime> #include <list> #include <numeric> #include <u...
#include<iostream> #include<algorithm> #include<vector> #include<cstdio> #include<cstring> #include<climits> #include<cmath> #include<map> #define f first #define s second #define mp make_pair #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++) #...
1
#include <algorithm> #include <iostream> #include <vector> #include <functional> using namespace std; template<typename Monoid> struct SegmentTree { using F = function<Monoid(Monoid, Monoid)>; const F f; const Monoid M1; int sz; vector<Monoid> dat; SegmentTree(int n, const F f, const Monoid &M1...
#if 0 2019.12.30 朴素 dp 设 f[i][p][q] 表示前 i 次操作后当前棋子为 (p, q) 的最小代价。 事实上由于第 i 次操作后一定有一个棋子是 x[i] ,因此可以优化一维: f[i][j] 表示前 i 次操作后当前棋子为 (j, x[i]) 的最小代价。 转移有两种: 1) f[i - 1][j] + |x[i - 1] - x[i]| -> f[i][j] 2) min(f[i - 1][k] + |x[i] - k|) -> f[i][x[i - 1]] 用线段树维护 f[~][j] ,第一种转移就是全局加,第二种是单点取 min 。 第二种转移可以把左边的绝对值拆开: f[i - 1][k...
1
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <tuple> #include <queue> #include <deque> #include <map> #include <set> #include <cmath> #include <iomanip> #include <cassert> #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(x) (x).begin(), (x).end() #d...
#include <stdio.h> #include <stdlib.h> #include <math.h> #define INIVAL 2147483647 int *a, *ts, c, s, t, v; void update(int k, int l, int r) { if (r<s || t<=l) return; if (s<=l && r<=t) { a[k] = v; ts[k] = c; } else if (l<r-1) { update(((k+1)<<1)-1, l, (l+r)>>1); update((k+1)<<1, (l+r)>>1, r); ...
1
#include <bits/stdc++.h> #define _overload(_1,_2,_3,name,...) name #define _rep(i,n) _range(i,0,n) #define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i) #define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__) #define _rrep(i,n) _rrange(i,n,0) #define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)...
#include<bits/stdc++.h> using namespace std; #define ll long long int #define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define endl "\n" #define REP(i,a,b) for(ll i=a;i<b;i++) #define PER(i,b,a) for(ll i=b;i>a;i--) #define forit(it,x) for(auto it=(x).begin();it!=(x).end();++it) #define ull unsigned long...
0
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<ll, ll>; const int MAX { 200010 }; const ll MOD { 998244353 }, oo { 1LL << 62 }; ll fs[MAX]; ll st[MAX][2]; void precomp() { fs[0] = fs[1] = 1; for (ll i = 2; i < MAX; ++i) fs[i] = (fs[i - 1] * i) % MOD; } ll mod_...
#include <bits/stdc++.h> #define rep(i, e, n) for (int i = e; i < (n); ++i) using namespace std; typedef long long ll; using P = pair<int,int>; const ll inf=1000000000007; int main() { ll n,a,b,c,d,e; cin >> n >> a >> b >> c >> d >> e; ll mn= min(min(min(a,b),c),min(d,e)); ll ans = (n-0.5)/mn +5; cout << ans...
0
#include <bits/stdc++.h> using namespace std; using ll=long long; #define int ll #define FOR(i,a,b) for(int i=int(a);i<int(b);i++) #define REP(i,b) FOR(i,0,b) int read(){ int i; scanf("%lld",&i); return i; } signed main(){ while(true){ int e=read(); int ans=100000; int m; if(e==0) break; int z,y,x; ...
#include <bits/stdc++.h> #define ll long long #define MODV 1000000007 #define INFLL LLONG_MAX // 9223372036854775807 #define EPS 1e-9 #define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++) #define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++) #define all(v) v.begin(), v.end() #define endl "\n" #defi...
0
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<n; ++i) int main() { int N; cin >> N; vector<int> x(N), y(N); rep(i,N) cin >> x[i] >> y[i]; double d=0; rep(i,N) rep(j,N) d += hypot(x[i]-x[j], y[i]-y[j]); printf("%.8f\n", d/N); }
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) #define all(v) v.begin(),v.end() #define len(x) (ll)(x).length() using namespace std; typedef long long ll; typedef pair<int,int> P; const int INF=1e9; const int di[] = {-1,0,1,0}; const int dj[] = {0,-1,0,1}; int main(){ double n; cin>>n; vector<v...
1
#include<iostream> #include<algorithm> #include<ctime> #include<vector> #include<string> #include<cmath> #include<map> #include<iomanip> #include<numeric> #include<queue> #include<deque> #include<cfloat> #include<functional> #include<tuple> #include<math.h> #include<bitset> #include<stack> #include<set> #include<random...
#include <bits/stdc++.h> using namespace std; void solve(long long N, long long K, std::vector<long long> D){ long long ans = 0; for(long long i = N; i < 100000; ++i){ //cout << i << endl; string S = to_string(i); bool check = true; for(auto s : S){ for(auto d : D){...
0
#include<iostream> using namespace std; int main() { int n; int i, j, k, l, m; int tmp; int count=0; cin >> n; int Dice[n][6]; for(i=0;i<n;i++){ for(j=0;j<6;j++){ cin >> Dice[i][j]; } } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ for(k=0;k<4;k++){ tmp=Dice[j][0]; Dice[j][0]=Dice[j][1]; ...
#include<iostream> #include<vector> using namespace std; vector<long> dp; vector<long> pre; void rec(int i, vector<int>& nottaken, long scoresofar, int mask, int group) { if(i==nottaken.size()) { dp[mask]=max(dp[mask],scoresofar+pre[group]); return; } rec(i+1,nottaken,scoresofar,mask,group); rec(i+1...
0
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fi first #define se second #define mp make_pair #define pb push_back #define fbo find_by_order #define ook order_of_key typedef long long ll; typedef pair...
#include <iostream> #include <vector> using namespace std; void solve() { int N, M; cin >> N >> M; vector<int> A(N); vector<int> B(M); for(int i = 0; i < N; ++i) { cin >> A[i]; } for(int i = 0; i < M; ++i) { cin >> B[i]; } vector<int> point(N); int max = 0; for(int i = 0; i < M; ++i) { for(int j =...
0
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ string s; cin>>s; if(s.length()<26){ char c='a'; rep(i,s.length()) if(s[i]==c) c++, i=-1; s+=c; cout<<s<<'\n'; } else{ string t=s; if(next_permutation(t.begin(),t.end())){ while(t.substr(0,t.length()-...
#include<stdio.h> int main(){ int x[32]={1,2,4}; for(int i=3;i<31;i++) x[i]=x[i-1]+x[i-2]+x[i-3]; int n; while(1){ scanf("%d",&n);if(n==0)break; int d=x[n-1]; int y=d/365/10+1; printf("%d\n",y); } return 0; }
0
#include<iostream> #include<string> using namespace std; class Base { public: Base() { score = 0; outNum = 0; first = false; second = false; third = false; } void hit() { if (third) { score++; } third = second; second = first; first = true; } void homerun() { if (first) { first = false...
#include <iostream> #include <vector> using namespace std; int main(){ int n, x; vector<int> a; cin>>n; for(int i=0;i<n;i++){ cin>>x; a.push_back(x); } for(int i=a.size()-1;i>=0;i--){ if(i != a.size()-1) cout<<" "; cout<<a[i]; } cout<<endl; return 0; }
0
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> using namespace std; //using namespace boost::multiprecision; typedef long long int ll; typedef long double ld; #define MOD 1000000007 #define ALL(obj) (obj).begin(),(obj).end() template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}ret...
#include <iostream> #include <set> using namespace std; int main() { long long N, L[2]{}; cin >> N; set<int> S; while (cin >> N) { if (!S.insert(N).second) { S.erase(N); if (N > L[0]) L[1] = L[0], L[0] = N; else if (N > L[1]) L[1] = N; } } cout << L[0] * L[1] << endl; }
0
#include <bits/stdc++.h> using namespace std; struct Node{ int key; Node *right,*left,*parent; }; Node *root,*NIL; Node * Min(Node *p){ while(p->left!=NIL) p=p->left; return p; } Node * find(Node *p,int a){ while(p!=NIL && a!=p->key){ if(a<p->key) p=p->left; else p=p->right; } return p; } Nod...
#include <bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, c; cin >> n; while (n != 0) { int hist[10] = {}; for (int i = 0; i < n; ++i) { cin >> c; hist[c]++; ...
0
// //AtCoder Beginner Contest 122 //C //https://atcoder.jp/contests/abc122/tasks/abc122_c // #include <iostream> #include <algorithm> #include <vector> #include <iomanip> #include <cmath> #include <ctime> #include <queue> #include <map> #include <set> #include <tuple> #include <functional> #include <cassert> #include ...
#pragma GCC optimize(2) #pragma GCC optimize("inline") #include <cstring> #include <cstdio> #include <algorithm> #include <vector> #include <queue> #define mp make_pair #define pb push_back using namespace std; typedef long long li; template<class T>inline void read(T &x) { x = 0; T tmp = 1; char c = getchar(); ...
0
#include <bits/stdc++.h> #define f(i,a,b) for(int i=a;i<=b;++i) using namespace std;int M=998244353,N,K,a,s[303],d[303][303][303]={1};main(){string S;cin>>S>>K;K=min((int)S.size(),K);for(auto c:S)c=='0'?++N:++s[N];f(i,0,N)f(j,0,K)f(k,0,j)f(l,-min(k,s[i]),K-j)(d[i+1][j+max(l,0)][k+l]+=d[i][j][k])%=M;f(i,0,K)(a+=d[N+1][i...
#include <bits/stdc++.h> int m; using namespace std; const int N = 302; string s; int f[N][N][N]; int a[N]; int main() { ios_base::sync_with_stdio(0); cin >> s; cin >> m; for (int i = 0; i < s.size(); i++) a[i + 1] = s[i] - 'a'; int n = s.size(); a[0] = -1; a[n + 1] = -1; f[1][n][0] = 0; for...
0
#include <bits/stdc++.h> #define REP(i, n) for(int i = 0; i < (n); i++) #define REP1(i, n) for(int i = 1; i <= (n); i++) #define REPD(i,a,b) for (int i=(a);i<(b);i++) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> v...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll LINF = 1e18; const int INF = 1e9; const ll MOD = 1000000007; int main(){ int a, b, c, k; cin >> a >> b >> c >> k; for(int i = 0; i < k; i++){ if(a < b){ if(b < c) c *= 2; else b *= 2; } ...
1
#include <string> #include <utility> #include <iostream> #include <algorithm> using namespace std; int main() { string S; cin >> S; for (string::size_type i = 0; i < S.size() / 2; i++) { swap(S[i], S[S.size() - i - 1]); } for (string::size_type i = 0; i < S.size(); i++) { cout << S[i]; } cout << endl...
#include <iostream> #include <algorithm> #include <vector> /*int main(int argc, char **argv) { int a, b, c, d, e; std::cin >> a >> b >> c >> d >> e; std::cout << std::min(a, std::min(b, c)) + std::min(d, e) - 50 << std::endl; return 0; }*/ /*int main() { int l, a, b, c, d; std::cin >> l >> a >> b >> c >> d; int...
0
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author champon */ #include <iostream> #include <fstream> #include <bits/stdc++.h> #define se cout << "test ok" << endl; #define sp << " " << #define enl "\n"; using namespace std; using ll=long long; using ld=long double; ll...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll N = 0; cin >> N; ll M = 0; cin >> M; vector<ll> p(M,0); vector<string> S(M); for(ll i = 0; i < M; i++) { cin >> p.at(i); cin >> S.at(i); } vector<int> A(N,0); vector<bool>...
0
#include <bits/stdc++.h> int solve() { int N, M; std::cin >> N >> M; std::vector<int> s(M); std::vector<int> c(M); for (int i = 0; i < M; ++i) std::cin >> s[i] >> c[i]; /* 全探索 */ for (int n = 0; n < std::pow(10,N); ++n) { int digit = 1; // 0は1桁 std::vector<int> each_num(1, n%10); // 一の位 i...
#include <bits/stdc++.h> #include <set> using namespace std; using pii = pair<int,int>; using pll = pair<long long, long long>; const long long INF = 1<<29; const int MOD = 1000000007; long long ruizyou(long long m,long long n){ if(m == 0)return 0; if(m == 1)return 1; long long ans = 1; long long tmp = m; fo...
1
#include <iostream> #include <iomanip> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <utility> #include <string> #include <cmath> #include <cstdlib> #include <cstring> #include <deque> #include <numeric> using namespace std; typedef u...
#include<bits/stdc++.h> using namespace std; int read(){ int x=0; char c=getchar(); int flag=1; while(!isdigit(c)) { if(c=='-') flag=-1; c=getchar(); } while(isdigit(c)) { x=((x+(x<<2))<<1)+(c^48); c=getchar(); } return x*flag; } const int mod=1e9+7; int n,k; int dp[2005][2005];//i个白球,j种颜色 int fac[4000005],Inv...
0
#include <bits/stdc++.h> using namespace std; int main(){ int n, k; cin >> n >> k; int l[n], ans = 0; for(int i=0; i<n; ++i) cin >> l[i]; sort(l, l+n, greater<int>()); for(int i=0; i<k; ++i) ans += l[i]; cout << ans << endl; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define For(i,n,k) for(int i=(n);i<(k);i++) #define ALL(a) (a).begin(),(a).end() vector<int> match = {-1,2,5,5,4,5,6,3,7,6}; void Main(){ int n,m; cin >> n >> m; vector<pair<int,int>> approval(m);//first:本数 second:数 For(i,0,m) { ...
0
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; using P = pair<int,int>; const int MOD = 1000000007; int main() { int a,b; cin>>a>>b; int c=a+b,d=a-b,e=a*b; c=max(c,d); c=max(c,e); cout<<c<<endl; }
#include<bits/stdc++.h> using namespace std; const int N=1000005,E=262144; const int M=998244353; int n,m,i,j,s,a[N],dp[6005][12005]; long long dfs(int i,int j) { if(i<0) return 0; if(i==0) if(j>=0&&j%3==0) return 1; else return 0; if(dp[i][j+6000]!=-1) return dp[i][j+6000]; long long s=dfs(i-1,j+1); ...
0
#include <bits/stdc++.h> #define ll long long using namespace std; const int N=5e5+50; int gi(){ char ch=getchar(); int x=0,q=0; while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar(); while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(); return q?-x:x; } int vis[N],d[N],head[N],nn[N][2],cnt=1,flag; ll ans; #de...
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; // グラフ型 typedef long long ll; #define _GLIBCXX_DEBUG int main() { ll N, M; cin >> N >> M; vector<ll> save(N+1, -1); for(ll i=0; i<M; i++){ ll a, b; cin >> a >> b; if(save[a] == -1){ save[a] = b; }else if...
0
#include <iostream> using namespace std; int main() { int n, i, x; cin >> n; i = 1; 3 <= n <= 10000; while (i <= n - 1) { i++; x = i; if (x % 3 == 0) { cout << " " << i; } else if (x % 10 == 3) { cout << " " << i; } else if ((x / 10) % 10 == 3) { cout << " " << i; } else if ((x...
#include<bits/stdc++.h> using namespace std; const int MAX_N = 2e5 + 5; string s; void solve(){ stack<char> st; int i = 0, n = s.length(); for(i = 0; i < n; i++){ if(s[i] == 'S') st.push(s[i]); else{ if(st.size() > 0 && st.top() == 'S') st.pop(); ...
0
#include<bits/stdc++.h> #define rint register int using namespace std; inline int read(){ int s=0,f=1; char c=getchar(); while(c<'0'||c>'9'){if(c=='-')f=0;c=getchar();} while(c>='0'&&c<='9') s=(s<<1)+(s<<3)+(c^48),c=getchar(); return f?s:-s; } const int Mod=1e9+7; int n,X,Y,Z,ed,ans=1; int f[50][1<<18]; int main(){...
#include <bits/stdc++.h> using namespace std; int n,x,y,z; typedef long long ll; const int N = 41, MAXM = (1 << 18) + 50, mod = (int)1e9 + 7; map<vector<int>, int> mp; int cnt = 0; int dp[N][MAXM]; int nxt[MAXM][11]; bool haiku[MAXM]; //vector<vector<int> > seqs; int cumul(vector<int> &V, int cur, int sum) { w...
1
#include <bits/stdc++.h> using namespace std; using ll =long long; #define all(v) v.begin(),v.end() int main() { set<ll> S; for(ll i=0;i<3;i++) { ll A; cin>>A; S.insert(A); } if(S.size()==2) { cout<<"Yes"<<endl; } else { cout<<"No"<<endl; } }
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define Opy ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) typedef long long ll; int main() { //Opy; /*------------------------------------------------- #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", ...
0
#include <bits/stdc++.h> #include <string> #include <vector> #include <algorithm> #include <math.h> #include <iostream> #include <numeric> #define rep(i,n) for (int i = 0;i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; #define chmax(x,y) x = max(x,y) int INF = 1e9; int main(){ int n...
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <cstdio> #include <cmath> #include <tuple> #include <iomanip> #include <numeric> #include <unordered_map> #include <sstream> #incl...
0
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) #define ALL(a) (a).begin(),(a).end() using namespace std; using ll = long long; using P = pair<int,int>; vector<int> num = {0,2,5,5,4,5,6,3,7,6}; vector<char> nchar = {'0','1','2','3','4','5','6','7','8','9'}; bool check(string s,string t){ i...
#include<bits/stdc++.h> #define fi first #define se second #define lc (x<<1) #define rc (x<<1|1) #define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++) #define mk make_pair #define pi pair<int,int> #define pb push_back #define IT iterator #define SZ(a) ((int)a.size()) #define all(a) a.be...
0
#include <bits/stdc++.h> #define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a) #define loop(i, s, n) loop2(i, s, n, 1) #define rep(i, n) loop(i, 0, n) #define pb push_back #define all(in) in.begin(),in.end() using ll = long long; using ull = unsigned long long; using namespace std; int main(){ int n...
#include <iostream> #include <cmath> #include <cstdio> using namespace std; int main(void) { double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; printf("%lf\n", sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2))); return 0; }
0
#include <iostream> #include <string> #include <algorithm> #include <vector> //#include <stack> //#include <queue> //#include <cstdio> #include <cmath> #include <iterator> #include <map> //#include <list> #include <iomanip> using namespace std; #define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #defin...
#include<stdio.h> int main() { int n, m, k; scanf("%d %d %d", &n, &m, &k); int sum1 = k/n; int sum2 = k/m; int ctr = 0; int temp; if(sum1 > sum2){ for(int i = 1; i <= 100; i++){ temp = m * i; ++ctr; if(temp >= k){ break; } } }else{ for(int i = 1; i <= 100; i++){ temp = n * i; ++ctr...
1
#include <bits/stdc++.h> using namespace std; const int MaxM = 110; int N, M, A[ MaxM ], Sum, Num; int main() { scanf( "%d%d", &N, &M ); for( int i = 1; i <= M; ++i ) scanf( "%d", &A[ i ] ); for( int i = 1; i <= M; ++i ) Sum += A[ i ]; if( Sum != N ) { printf( "Impossible" ); return 0; } for( int i = 1; i <...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> P; typedef pair<ll,ll> l_l; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; typedef pair<l_l,ll> lll; typedef vector<string> vs; const ll dx[4]={1,-1,0,0}; const...
0
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <array> #include <queue> #include <deque> #include <map> #include <set> #include <sstream> #include <cstdio> #include <cstring> #include <cmath> #include <list> #include <numeric> #include <stack> #include <iomanip> #include <random> ...
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for(int i=0; i<n; i++) #define rep1(i, n) for(int i=1; i<=n; i++) #define repr(i, n) for(int i=n-1; i>=0; i--) #define repr1(i, n) for(int i=n; i>=1; i--) #define all(v) v.begin(),v.end() using ll = long long; using pii = pair<int, int>; using pil = pair<in...
0
#include<iostream> using namespace std; #include<string> #include<strstream> #include<sstream> #include<algorithm> #include<math.h> bool issqr(int n) { double d = sqrt(n); double x = floor(d); if (d - x == 0) return true; else return false; } int main() { int n; cin >> n; for (int i = n; i >= 0; --i) { i...
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define inf 1000000000 #define IOS ios_base::sync_with_stdio(0);cin.tie(0) #define meM(y,a) memset(y,a,sizeof y) #define sC(a) scanf("%d",&a) #define alL(a) a.begin(),a.end() #define prinT(a,sz) co...
0
#include <bits/stdc++.h> #define INF 1e9 #define endl '\n' #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i) #define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i) #define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i) #define ALL(x) (x).begin(...
#include <bits/stdc++.h> #define PI 3.14159265359 #define rep(i,a,n) for(int i=a;i<(int)n;++i) #define SZ(x) ((int)(x).size()) //size() unsigned -> int #define descSort(a) sort(a.begin(),a.end(),std::greater<int>()) using namespace std; typedef long long ll; const ll INF = 1e9 + 7; int main() { int n; cin>>n;...
1
/** * author: tourist * created: 06.07.2020 09:38:22 **/ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int x, y; cin >> x >> y; int ans = 0; if (x <= 3) { ans += (4 - x) * 100000; } if (y <= 3) { ans += (4 - y) * 100000; }...
#include <bits/stdc++.h> #define mset(a, b) memset(a, b, sizeof(a)) #define mcpy(a, b) memcpy(a, b, sizeof(a)) #define rg register using namespace std; typedef long long LL; const int MAXN = 200005; const LL INF = 0x3f3f3f3f3f3f3f3f; template <typename T> inline void read(T &AKNOI) { T x = 0, flag = 1; char ch = get...
0
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define repr(i,n) for(int i = (int)(n); i >= 0; i--) #define all(v) v.begin(),v.end() typedef long long ll; int main(){ int N; cin >> N; vector<pair<int,int> > red(N); vector<pair<int,int> > blue(N); re...
#include <iostream> #include <string> #include <cstring> #include <algorithm> #include <functional> #include <cmath> #include <set> #include <queue> #include <deque> #include <vector> #include <climits> #include <sstream> #include <iomanip> #include <map> #include <stack> using namespace std; typedef unsigned long long...
1
#include <iostream> #include <bitset> #include <vector> #include <string> #include <algorithm> #include <set> #include <map> #include <stack> #include <cmath> #include <regex> #include <iomanip> #include <climits> #include <utility> #include <queue> using namespace std; using ll = long long int; using dd = long double;...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; string res = "AC"; int C_cnt = 0; if (s.at(0) == 'A') { for (int i = 1; i < s.size(); i++) { if (s.at(i) == 'C') { if (2 <= i && i <= (s.size()-2)) { C_cnt++; ...
1
#include<bits/stdc++.h> #define watch(x) cout << (#x) << " is " << (x) << endl #define endl "\n" typedef long long ll; using namespace std; int static fast = [](){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); return 0; }(); // freopen("input.txt", "r", stdin); int main() { int n; string s, t; ...
#include <bits/stdc++.h> using namespace std; int main() { long long int N; string s,t; cin>>N>>s>>t; long long len1,len2,count=0; len1=s.length(); len2=t.length(); if(len1==len2&&len1==N&&N>=1&&N<=100){ if (N>=len1+len2){ count=N; } else { count=len1+len2; for(int i=0;i<=l...
1
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <iomanip> using ll = long long; using uint = unsigned int; using graph = std::vector<std::vector<ll>>; using wGraph = std::vector<std::vector<std::pair<l...
#include <iostream> using namespace std; void call(int n); void judge1(int a); void judge2(int b); void judge3(int c); int main() { int input; cin>>input; call(input); return 0; } void call(int n) { int i; for (i = 1; i <= n; i++) { judge1(i); } cout << endl; } void judge1(int a) { if (a % 3 == 0) cout <...
0
#include<bits/stdc++.h> using namespace std; int main() { int n,m; int sum = 0; cin >> n; m = n; for(int i = 0; n > 0; ++i){ sum += n%10; n /= 10; } if(m%sum==0) cout << "Yes" << endl; else cout << "No" << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1000000009; const ll LINF = 1e18; int cal_digit(ll n) { int rtn = 0; while (n) { ++rtn; n /= 10; } return rtn; } int main() { ll n; cin >> n; int rtn = INF; for (ll a = 1; a * a <= n; ...
0
#include <iostream> #include <stdio.h> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <iomanip> #include <queue> #include <deque> #include <map> #include <unordered_map> #define rep(i,n) for(int i=0;i<n;i++) #define repn(i,n) for(int i=1;i<=n;i++) #define repr(e,x) for(auto& e:x) usi...
#include<bits/stdc++.h> //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); //clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl; using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; typedef pair<int,int> pii; typedef pair<pii,int> p...
1
#include <iostream> #include <stdio.h> #include <math.h> #include <string.h> #include <time.h> #include <stdlib.h> #include <string> #include <bitset> #include <vector> #include <set> #include <map> #include <queue> #include <algorithm> #include <sstream> #include <stack> #include <iomanip> #include <assert.h> using na...
#include<bits/stdc++.h> using namespace std; template<typename T>inline T read(){ T f=0,x=0;char c=getchar(); while(!isdigit(c)) f=c=='-',c=getchar(); while(isdigit(c)) x=x*10+c-48,c=getchar(); return f?-x:x; } namespace run{ const int N=6009;int mod; inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;} int...
1
#include <bits/stdc++.h> using namespace std; #define ALL(x) (x).begin(),(x).end() #define COUT(x) cout<<(x)<<"\n" #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define REP(i, n) for(int i=0;i<n;i++) #define YES(x) cout<<(x?"YES":"NO")<<"\n" #define Yes(x) cout<<(x?"Yes":"No")<<"\n" #define dump(x) cout...
#include <stdio.h> int main(void) { char line[80]; int l[10], v[2]; while (true) { if (fgets(line, sizeof line, stdin) == NULL) { break; } if (sscanf(line, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &(l[0]), &(l[1]), &(l[2]), &(l[3]), &(l[4]), &(l[5]), &(l[6]), &(l[7]), &(l[8]), &(l[9]), ...
0
#include <bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0) #define AfterDecimal(n) cout << fixed << setprecision(n); #define ll long long int #define ld long double #define all(a) a.begin(), a.end() #define pii...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; int main() { int R; cin >> R; string S; if (R < 1200) S = "ABC"; else if (R < 2800) S = "ARC"; else S = "AGC"; cout << S << endl; return 0; }
0
#include <bits/stdc++.h> using namespace std; // ----------- define -------------- #define int long long #define vi vector<int> #define vc vector<char> #define ii pair<int,int> #define fi first #define sc second #define all(x) (x).begin(),(x).end() #define get_bit(x, k) ((x >> k) & 1) // ------------------------------...
#ifdef __GNUC__ #pragma GCC target("avx2") #pragma GCC optimize ("O30") #pragma GCC optimize ("tree-vectorize") #pragma GCC optimize("unroll-loops") #define iss std::cin #endif #include "bits/stdc++.h" #define rep(i, times) for(ll i = 0; i < (times); ++i) #define p(x) (cout << (x) << "\n") using ll = long long; using l...
0
#include <iostream> #include <algorithm> #include <vector> #include <cstring> #include <cstdio> #include <map> #include <set> #define LL long long #define pb push_back #define mp make_pair #define INF 0x3f3f3f3f #define Inf 1000000000000000000LL #define F first #define S second using namespace std; typedef pair<int,int...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5+2; int pre1[MAXN],pre2[MAXN]; int finds(int x,int *pre) { return pre[x] == x? pre[x]:pre[x] = finds(pre[x],pre); } void join(int x,int y,int *pre) { int px = finds(x,pre); int py = finds(y,pre); if( px!=py) { pre[px] = py; ...
0
#include <iostream> #include <algorithm> #include <iomanip> #include <string> #include <vector> #include <math.h> #include <queue> #include <deque> #include <stack> #include <set> #include <map> const int MOD = 1e9+7; const int MOOD = 998244353; #define PI 3.14159265359 typedef long long ll; using namespace std; int d...
#include <bits/stdc++.h> #define REP(i, e) for(int (i) = 0; (i) < (e); ++(i)) #define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i)) #define ALL(c) (c).begin(), (c).end() #define PRINT(x) cout << (x) << "\n" using namespace std; using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>; const long ...
1
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int mxn= 5e5+5; #define mod 1000000007 #define endl '\n' void rishabh(){ ios_base::sync_with_stdio(false); cin.tie(NULL); } vector<array<ll,2>> adj[mxn]; bool vis[mxn]; ll ans=0,w,check; ll dfs(int i, ll temp, int j){ vis[i]=true; ...
#include <bits/stdc++.h> using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; bitset<13000> dp[8...
0
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int h1,m1,h2,m2,k; cin>>h1>>m1>>h2>>m2>>k; cout<<(h2*60+m2)-(h1*60+m1)-k<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; using usize = ::std::size_t; using u64 = ::std::int_least64_t; static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2; u64 N; vector<u64> a, parent, visited; void findpath(u64 i){ if (parent[i] != -1) { findpath(parent[i]); } ...
0
#include <bits/stdc++.h> using namespace std; bool dfs(int i, int nowcolor, vector<vector<int>> &way, vector<int> &color) { color.at(i) = nowcolor; for(int j = 0; j < way.at(i).size(); j++) { if(color.at(way.at(i).at(j)) == nowcolor) { return false; } else if(color.at(way.at(i).at(j)) == -1) { ...
#include <bits/stdc++.h> using namespace std; int main() { int N,M; cin >> N >> M; int ans = -1; vector<int> s(M); vector<char> c(M); for (int i=0;i<M;i++) cin >> s[i] >> c[i]; for (int i = (N==1) ? 0 : pow(10, N-1);i<pow(10,N);i++){ string x = to_string(i); bool can = true; ...
0
#include <bits/stdc++.h> using namespace std; #define ll long long #define PII pair<ll,ll> #define VI vector<ll> #define VB vector<bool> #define VC vector<char> #define VVI vector<vector<ll>> #define VVC vector<vector<char>> #define VS vector<string> #define VP vector<PII> #define lf(i,a,b) for(ll i=a;i<=b;i++) #...
//thuanqvbn03 #include <bits/stdc++.h> using namespace std; int n; int a[16][16]; long long dp[1 << 16]; int GetBit(int num, int pos) { return (num >> pos) & 1; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { for (...
1
#include <bits/stdc++.h> using namespace std; int main() { int N,M; cin >> N >> M; if (M == 1){ cout << 1 << ' ' << 2 << endl; return 0; } if (N % 2 == 1){ for (int i = 0; i < M; i++) { cout << i+1 << ' ' << M*2 - i << endl; } } else { for (int i = 0; i < (M+1)/2; i++) { ...
#include <bits/stdc++.h> typedef long long ll; using namespace std; ll MOD = 1000000007; #define vec vector<int> #define vecll vector<ll> #define vecd vector<double> #define vecst vector<string> #define vecb vector<bool> #define vec2(var, n, m) ve...
0
#include <bits/stdc++.h> #include <iomanip> #include <math.h> #include <unistd.h> //#include <stdio.h> #define rep(i,x) for(ll i = 0;i<x;i++) #define all(a) (a).begin(),(a).end() using ll = long long; using ld = long double; using namespace std; using dou = double; const ll INF = 1LL << 60; const ll mod = 1000000007; t...
// #include<bits/stdc++.h> // using namespace std; // #define ll long long int // #define maxn 100005 // int main(){ // ios::sync_with_stdio(0); // cin.tie(0); // cout.tie(0); // ll t=1; // //cin>>t; // while(t--){ // int n; // cin>>n; // double d; // ll x; // int num2,...
0
#include <bits/stdc++.h> using namespace std; int main() { long long i,j,k,a,b,c=0,n,t; cin>>n; long long A[n]; for(i=0;i<n;i++) cin>>A[i]; sort(A,A+n); for(i=0;i+2<n;i++) { for(j=i+1;j+1<n;j++) { for(k=j+1;k<n;k++) { if(A[i]!=A[j]&&A[j]!=A[k]&&A[k]!=A[i]&&A[i]+A[j]>A[k]) c++; } }...
//#include"bits/stdc++.h" #include<iostream> #include<ostream> #include<vector> #include<string> #include<algorithm> #define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++) #define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) RFOR(i,0,n) #define ...
0
#include <bits/stdc++.h> using namespace std; int main() { long N; cin>>N; vector<vector<long>> a(100005,vector<long>(2)); vector<vector<long>> b(100005,vector<long>(2)); long al=0,bl=0; for(int i=0;i<N;i++){ long v; cin>>v; if(i%2==0) a[v][0]++,al++; else b[v][0]++,bl++; } for(int i=0;...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long int main(){ ll n; cin >> n; vector<ll> a(n),ev(100001),od(100001); rep(i,n){ cin >> a.at(i); if(i%2==0){ od.at(a.at(i))++; }else{ ev.at(a.at(i))++; } } ll maxie...
1
#include <iostream> #include <vector> using namespace std; int main() { int n; while (cin >> n, n){ long long e[5000] = {0}, p, q, t; bool out = false, f = false; vector<int> s; for (int i = 0; i < n; i++){ cin >> t >> p >> q; for (int j = 0; j < s.size(); j++){ if (s[j] == t){ f = true; ...
#include <iostream> #include <string> #define REP(i,k,n) for(int i=k;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) using namespace std; string s[12]; int dx[4] = {1,0,-1,0}; int dy[4] = {0,1,0,-1}; void dfs(int x,int y) { s[x][y] = '0'; rep(i,4) { int nx = x + dx[i]; int ny = y + dy[i]; if(0 <= nx && n...
0
#include <iostream> #include <stdio.h> #include <math.h> #include <string> using namespace std; int main() { double x1, y1, x2, y2, num, ans = 0, dou = 1, xx; cin >> x1 >> y1 >> x2 >> y2; num = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1); while (dou < num) { dou *= 10; } xx = dou; for (int i = 0; i < 100; i++) ...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; int main() { double x1, y1, x2, y2; scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2); printf("%lf", sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))); }
1
#include <iostream> using namespace std; int f[102][102]; bool dfs(int ys,int xs,int yg,int xg,int c){ if(f[ys][xs]!=c)return 0; if(ys==yg && xs==xg)return 1;; f[ys][xs]=0; bool flag=0; flag += dfs(ys+1,xs,yg,xg,c); flag += dfs(ys-1,xs,yg,xg,c); flag += dfs(ys,xs+1,yg,xg,c); flag += dfs(ys,xs-1,yg,...
#include <bits/stdc++.h> using namespace std; #define FOR(i, s, n) for(int i = s; i < (int)n; i++) #define per(i, n) for(int i = n; i >= 0; i--) #define ROF(i, s, n) for(int i = s; i >= (int)n; i--) #define FORIT(i, A) for (auto i : A) #define PRINT(x) cout << (x) << "\n" #define ALL(a) (a).begin(),(a).end() #define RA...
1
#include <bits/stdc++.h> using namespace std; /* typedef */ typedef long long ll; typedef pair<int, int> pii; /* constant */ const int INF = 1 << 30; const ll LINF = 1LL << 50; const int NIL = -1; const int MAX = 10000; const int mod = 1000000007; const double pi = 3.141592653589; /* global variables */ /* function */ ...
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define int long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, n) for (int i = 0; i < n; ++i) #define range(i,a,b) ((a)<=(i) && (i)<(b)) #define debu...
0
#include<cstdio> #include<algorithm> using namespace std; const int N=1001000; int ii,i,j,k,l,n,m,ch,Last,ans; char s[N],t[N],f[N]; struct cc { int x,l,r;} A[N]; int main() { scanf("%d",&n); scanf("%s",s+1); scanf("%s",t+1); for (i=1;i<=n;i++) if (s[i]!=t[i]) break; if (i>n) return puts("0"),0; Last=n; for (i=n;...
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> a(n); bool f_zero = false; int num_m = 0; long long s = 0; int m = 1e9; for(int i=0; i<n; i++){ cin >> a[i]; if(a[i]==0) f_zero = true; if(a[i]<0) num_m++; s += abs(a[i]); m = min(m,abs(a[i])); } if(f_zero || nu...
0
#include <stdio.h> #include <iostream> #include <algorithm> #include <math.h> using namespace std; struct Info{ int number; }; void strcpy(char* to,char* str){ for(int i=0;str[i] != '\0';i++){ to[i] = str[i]; to[i+1] = '\0'; } } //base??¨comp??????????????????????????¢??° bool strCmp(char* base, char* comp){...
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> #include<iostream> #include<sstream> #include<string> #include<vector> #include<queue> #include<set> #include<map> #include<utility> #include<numeric> #include<algorithm> #include<bitset> #include<complex> using namespace std; type...
1
#include<iostream> #include<vector> #include<string> #include<algorithm> using namespace std; class crop{ public: string name; int price,seeding,youngL,L,flower, fruit,numFruit,fruitPrice,times; int StoL,LtoFruit,totaltime; double sum; crop(); crop(string name,int price,int seeding,int youngL, i...
#include <iostream> using namespace std; int main() { int n; cin >> n; int k[100]; char s[101]; while (n != 0) { for (int i = 0; i < n; i++) cin >> k[i]; cin >> s; int j = 0; for (int i = 0; s[i] != '\0'; i++) { if (s[i] >= 'a') s[i] -= 6; s[i] -= k[j]; if (s[i] < 'A') s[i] += 52; j++; if ...
0
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define input_output freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define ll long long #define read1(x) ...
#include "bits/stdc++.h" using namespace std; #ifndef LOCAL #define endl '\n' #endif #define fr(i, a, b) for(int i = a; i <= b; i++) #define rf(i, a, b) for(int i = a; i >= b; i--) #define pf push_front #define pb push_back #define eb emplace_back #define fi first #define se second #define all(x) x.begin(), x.end() #d...
0
#include <bits/stdc++.h> #define ri register #define int long long #define E (n+1) using namespace std; const int N=200010; inline int read() { int s=0, w=1; ri char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); } while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); ret...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n), b(n), c(n); for (auto &x: a) cin >> x; for (auto &x: b) cin >> x; for (auto &x: c) cin >> x; sort(a.begin(), a.end()); sort(b.begin(), b.end()); sort(c.begin(), c.end()); vector<long lo...
1
#include <stdio.h> #include <cstdio> #include <iostream> #include <iomanip> #include <queue> #include <set> #include <vector> #include <string> #include <cstring> #include <algorithm> #include <cmath> #include <complex> int main(){ // read problem long long int M, tmp1, tmp2; std::vector<long long int> d, c; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i) #define rreps(i, n) for (int i = ((int)(n)); i > 0; --i) #define rep2(i, s, n) for (int i = (s); i <...
1
#include<iostream> using namespace std; int main (void) { int r; cin>>r; r=r*2*3141592; cout<<r/1000000<<"."<<r%1000000; }
#include<bits/stdc++.h> using namespace std; #define pi acos(-1) int main(){ int r; cin >> r; cout << fixed << setprecision(20) << (2*r*pi) << endl; return 0; }
1
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define eb emplace_back typedef long long ll; typedef pair<int, int> pi; typedef vector<int> vi; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (i...
#include<bits/stdc++.h> const int N=503; using namespace std; typedef long long ll; ll a[N][N]; int n,p[N*2],tot; bool np[N*30]; inline int F(int x){ return p[n+x/2]; } inline int G(int x){ return p[(x+n/2*2)/2]; } int main(){ scanf("%d",&n); for(int i=2;tot<2*n;i++){ if(!np[i])p[tot++]=i; for(int j=i*i;j<N*30;...
1
/*{{{*/ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<string> #include<iostream> #include<sstream> #include<set> #include<map> #include<queue> #include<bitset> #include<vector> #include<limits.h> #include<assert.h> #define SZ(X) ((int)(X).size()) #define ALL(X) (X).be...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=100005; struct sj{ int a,l,r;ll x; inline sj(){} inline sj(int a,int l,int r,ll x):a(a),l(l),r(r),x(x){} inline bool operator<(const sj &t)const{return x>t.x;} }d[N]; inline void cmax(ll &a,ll b){if(a<b)a=b;} inline ll Y(int i,ll k){ ll...
1
#include<bits/stdc++.h> using namespace std; struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io; typedef long long ll; typedef long double db; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<vi> vii; typedef pair<int, int> pi; typedef tuple<int, int, int> t3; typedef map<int, int> mi; #de...
#include <bits/stdc++.h> // statics using namespace std; using int64 = int_fast64_t; using PAIR = pair<int, int>; constexpr int INF = 1 << 30; constexpr int64 LINF = 1LL << 60; constexpr int MOD = 1e9 + 7; constexpr int MAX_N = 1e5 + 1; // init/input #define int int64 #define INIT ios::sync_with_stdio(false);cin.tie(0...
1
#include <iostream> #include <iomanip> #include <utility> #include <cmath> #include <random> #include <vector> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <string> #include <algorithm> using namespace std; #define rep(i,n) for(int i = 0; i<n; ++i) #define REP(i,n) for(int ...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <tuple> #include <cstdint> #include <cstdio> #include <map> #include <queue> #include <set> #include <stack> #include <deque> #include <unordered_map> #include <unordered_set> #include <bitset> #include <cctype> #in...
0
#include <bits/stdc++.h> #include <math.h> #define _GLIBCXX_DEBUG #define _LIBCPP_DEBUG 0 using namespace std; #define ll long long #define rep(i,n) for (int i = 0; i < n; i++) #define rrep(i,n) for (int i = n-1; i >= 0; i--) #define MOD (1000000007) #define vi vector<int> #define vl vector<ll> #define vb vector<bool>...
#pragma region Macros #include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; using WGraph = vector<vector<pair<int, ll>>>; template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; } template<class T>inline bool chmin(T &a, ...
1
#include <bits/stdc++.h> using namespace std; int main(){ vector<queue<char>> s(3); for(int ix=0;ix<3;ix++){ string tmp; cin >> tmp; for(int ixx=0;ixx<tmp.size();ixx++) s.at(ix).push(tmp.at(ixx)); } char card; int turnplayer = 0; while(!s.at(turnplayer).empty()){ ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main(){ string sa,sb,sc; cin>>sa>>sb>>sc; reverse(sa.begin(),sa.end()); reverse(sb.begin(),sb.end()); reverse(sc.begin(),sc.end()); queue<char> card; card.push(sa[sa.size()-1]); ...
1
#include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define endl "\n" using namespace std; using ll = long long; using P = pair<int, int>; const ll MOD = 1000000007LL; // = 10^9 + 7 const double PI = 3.14159265358979; void solve() { int n, v1, v2; cin >> n; m...
#include <bits/stdc++.h> using namespace std; int main(int argc, const char *argv[]) { int n; cin >> n; int max_v = 100000; vector<int> va(n), cnt1(max_v + 1, 0), cnt2(max_v + 1, 0); for (int i = 0; i < n; ++i) { cin >> va[i]; if (i % 2 == 0) { cnt1[va[i]]++; } else { cnt2[va[i]]++; ...
1
#include<bits/stdc++.h> using namespace std; #define int long long #define ii pair <int, int> #define app push_back #define all(a) a.begin(), a.end() #define bp __builtin_popcountll #define ll long long #define mp make_pair #define f first #define s second #define Time (double)clock()/CLOCKS_PER_SEC ii mer(int a, int ...
/** * author: tourist * created: 29.12.2019 21:02:36 **/ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; for (int t = 0; t < 4; t++) { vector<int> a(n + 2); a[0] = t & 1; a[1] = (t & 2) >...
0
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int ans = 0; for ( int n = a; n <= b; n++ ) { string num = to_string(n); if ( num[0] == num[4] && num[1] == num[3] ) { ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int A, B; cin >> A >> B; int x = 0; int C = A; for (int i = 0; i < B - A + 1; i++) { int y = C / 10000 + C / 1000 % 10 *10 + C / 100 % 10 * 100 + C / 10 % 10 * 1000 + C % 10 * 10000; if ( C == y ){ x += 1; } ...
1
#include <iostream> int main(){ int n; std::cin>>n; std::cout<<(n-2)*180; }
#include<iostream> #include<stdio.h>//printf("%.*f\n",*********); #include<vector>//s.erase(n),vector #include<algorithm>//next_permutation #include<set> #include<string>//char('a'=32+'A') //to_string,string,substr #include<sstream> #include<complex> #include<time.h> #include<random> #include<cmath>//mi...
1
#include<algorithm>//sort,二分探索,など #include<bitset>//固定長bit集合 #include<cmath>//pow,logなど #include<complex>//複素数 #include<deque>//両端アクセスのキュー #include<functional>//sortのgreater #include<iomanip>//setprecision(浮動小数点の出力の誤差) #include<iostream>//入出力 #include<iterator>//集合演算(積集合,和集合,差集合など) #include<map>//map(辞書) #include<numer...
#include <iostream> #include <string> #include <cstring> #include <algorithm> #include <functional> #include <cmath> #include <set> #include <queue> #include <deque> #include <vector> #include <climits> #include <sstream> #include <iomanip> #include <map> #include <stack> using namespace std; typedef unsigned long long...
1
/* ID: anonymo14 TASK: wormhole LANG: C++ */ #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<pair<int,int>> vpii; #define F first #define S second #define PU push #define PUF push_front #define PUB push_back #d...
#include <bits/stdc++.h> using namespace std; int main() { int A,B; cin >> A >> B; if(A>B){ cout << A+max(A-1,B) << endl; return 0; } cout << B+max(B-1,A) << endl; }
1
#include <iostream> #include <iomanip> #include<math.h> #include<list> #include <algorithm> #include<set> #include<vector> #include<math.h> #include<map> #include<string> #include <numeric> #include <queue> #include <sstream> #include <bitset> #include<stack> using namespace std; using ll = long long; using vll = vect...
#include<iostream> #include<cmath> using namespace std; int main() { int R; scanf("%d",&R); printf("%f",2*R*acos(-1.0)); return 0; }
0
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ldouble = long double; const ll inf = 1ll << 60; const ll mod = (ll)1e9 + 7; #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define print(s) cout << s; #define println(s) cout << s << ...
#include<stdio.h> int main(){ char word1[105]; char word2[105]; scanf ("%s %s", &word1, &word2); printf("%s%s\n",word2,word1); return 0; }
0
#include <iostream> #include <iomanip> #include <cstdio> #include <queue> #include <cstring> #include <vector> #include <map> #include <algorithm> #include <cctype> #include <cmath> #include <bitset> #include <set> #include <stack> using namespace std; #define REP(i,n) for(int i=0;i<(int)(n);i++) #define RREP(i,n) for...
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include ...
0
#include<bits/stdc++.h> using namespace std; using ll = long long; #define REP(i,n) for(int i = 0;i < n;i++) /* * verified : http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4713284#1 * last revised : 29.July.2020 */ template<class T> class BIT { private: int n; vector<T> dat;//[1,n] public: BIT(int maxn, in...
#include<stdio.h> #include<math.h> #include<stdlib.h> #include<vector> #include<algorithm> #include<map> using namespace std; double pi = 3.1415926535897932384646433; typedef long long ll; typedef pair<ll, ll>pii; ll ccw(pii a, pii b, pii c) { return (b.first - a.first)*(c.second - b.second) - (b.second - a.second)*(...
0
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_string(const str...
#include <bits/stdc++.h> using namespace std; int ts[200010]; int main(){ int n, t; scanf("%d%d", &n, &t); for(int i = 0; i < n; i++) scanf("%d", &ts[i]); long ans = t; for(int i = 0; i + 1 < n; i++) { int time = ts[i+1] - ts[i]; ans += (time > t) ? t : time; } printf("%ld\n", ans); }
1