text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main(){ int x,y,z; cin >> x >>y >>z; cout << z<<endl <<x<<endl <<y; }
#include<cstdio> int a, b, c; int main() { scanf("%d %d %d", &a, &b, &c); printf("%d %d %d\n", c, a, b); }
#include <bits/stdc++.h> using namespace std; int x, y, z; int main(){ cin >> x >> y >> z; cout << z << " " << x << " " << y; }
#include<bits/stdc++.h> using namespace std; int main() { int x,y,z,tmp; cin>>x>>y>>z; cout<<z<<" "<<x<<" "<<y; }
#include <bits/stdc++.h> using namespace std; int main(void){ int x,y,z; cin>>x>>y>>z; cout<<z<<' '<<x<<' '<<y<<endl; }
#include <iostream> using namespace std; int main(){ int x, y, z; cin >> x >> y >> z; cout << z << " " << x << " " << y << endl;; }
#include <iostream> int main() { int x, y, z; std::cin >> x >> y >> z; std::cout << z << ' ' << x << ' ' << y; }
#include<iostream> int main(){ long long int a,b,c; std::cin >> a >> b >> c; std::cout << c << " " << a << " " << b; return 0; }
#include <iostream> using namespace std; int main() { int X, Y, Z; cin>>X>>Y>>Z; cout<<Z<<' '<<X<<' '<<Y; }
#include <iostream> using namespace std; int main(void){ long long t1, t2, a1, a2, b1, b2, c1, c2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; c1 = (a1 - b1) * t1; c2 = (a2 - b2) * t2; if(c1 < 0){ c1 *= -1; c2 *= -1; } if(c1+c2 == 0){ puts("infinity"); return 0...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll t1,t2,a1,a2,b1,b2;cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; if(t1*a1+t2*a2==t1*b1+t2*b2){ cout << "infinity" << endl; return 0; } ll c1=a1-b1; ll c2=a2-b2; if(c1<0){ c1*=-1; c2*=-1; } if(c1*t1+c2*t2>0){ ...
#include <bits/stdc++.h> #define l_ength size const int inf = (1<<30); const int mod = 1000000007; using ll = long long; using namespace std; int main(){ ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; if( a1 < b1 ){ swap(a1, b1); swap(a2, b2); } // かならず a1 > b1 ll d = (t1*a1+t2*a2) - (t1*...
#include <cstdio> #include <algorithm> int main() { long long t1, t2; long long a1, a2; long long b1, b2; scanf("%lld%lld%lld%lld%lld%lld", &t1, &t2, &a1, &a2, &b1, &b2); if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) { puts("infinity"); } else { long long dif = (t1 * a1 + t2 * a2) - (t1 * b1 + ...
#include<iostream> using namespace std; int main() { long long t1,t2,a1,a2,b1,b2,c,d,n,res; cin >> t1 >> t2; cin >> a1 >> a2; cin >> b1 >> b2; if(a1>b1){ c=t1*(a1-b1); d=t2*(b2-a2)-c; }else{ c=t1*(b1-a1); d=t2*(a2-b2)-c; } if(d<0){ cout << "0" << endl; return 0; } if(d==0){ ...
#include <bits/stdc++.h> using namespace std; using i64 = long long; int main() { i64 t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; i64 p = (a1 - b1) * t1, q = (a2 - b2) * t2; if (0 < p) { p *= -1; q *= -1; } if (p + q < 0) cout << 0 << endl; else if (p + q == 0) cout...
#include <bits/stdc++.h> #define Int int64_t using namespace std; int main() { Int T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; Int P = T1 * (A1 - B1); Int Q = T2 * (A2 - B2); if (P > 0) { P *= -1; Q *= -1; } if (P + Q == 0) { cout << "infinity" << endl; return 0; } if (P + Q <...
#include <bits/stdc++.h> using namespace std; using lint = long long; signed main(){ lint t1, t2; cin >> t1 >> t2; lint a1, a2, b1, b2; cin >> a1 >> a2 >> b1 >> b2; lint P = (a1 - b1) * t1; lint Q = (a2 - b2) * t2; if(P > 0) P *= -1, Q *= -1; if(P == -Q){ cout << "infinity" << endl; return 0; } if(P + Q < ...
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9 + 7; int main() { ll T1, T2; cin >> T1 >> T2; ll A1, A2; cin >> A1 >> A2; ll B1, B2; cin >> B1 >> B2; if (A1 > B1) { swap(A1, B1); swap(A2, B2); } ll diff = A1 * T1 + A2 * T2 - (B1*T1 + B2 * T2);...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1LL<<62 #define inf 1000000007 int main() { ll t1,t2,a1,a2,b1,b2; cin>>t1>>t2>>a1>>a2>>b1>>b2; if(a1<b1){ swap(a1,b1); swap(a2,b2); } ll ma=(a1-b1)*t1; ll mi=ma+t2*(a2-b2); if(mi==0){ cout<< "infinity"; } else if(mi>0){ co...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int,int>; #define rep(i,s,n) for(int i = s; i < (int)(n); i++) int main() { int t1,t2;ll a1,a2,b1,b2,p,q; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; p = (a1-b1)*t1;q = (a2-b2)*t2; if(p > 0){p *= -1;q *= -1;} if(p+q < 0){cout << ...
#include <bits/stdc++.h> using namespace std; using ll=long long; int main(){ ll t1,t2,a1,a2,b1,b2; cin>>t1>>t2>>a1>>a2>>b1>>b2; ll x1=t1*a1,x2=t2*a2,y1=t1*b1,y2=t2*b2; if(x1+x2==y1+y2){ cout<<"infinity"<<endl; return 0; } if((x1+x2)>(y1+y2) && a1>b1){ cout<<0<<endl; return 0; }else if((x1+...
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main(){ long long t1,t2,a1,a2,b1,b2; cin>>t1>>t2>>a1>>a2>>b1>>b2; long long d1=(b1-a1)*t1,d2=(b2-a2)*t2; if(d1+d2==0){ cout<<"infinity"; return 0; } if(d1<0){ d1*=-1; d2*=-1; } if(d1+d2>0){ cout<<0;r...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1000000007; const ll mod998 = 998244353; const ll intmax = 2147483647; const ll llmax = 9223372036854775807; const char sp = ' '; ll T1, T2, A1, A2, B1, B2; int main() { cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; A1 -= B1; A2 -= B2; ...
#include <bits/stdc++.h> #define Int int64_t using namespace std; int main() { Int T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; Int Tx = T1 * A1 + T2 * A2; Int Ax = T1 * B1 + T2 * B2; if (Tx == Ax) { cout << "infinity" << endl; return 0; } Int Tx1 = T1 * A1; Int Ax1 = T1 * B1; if (...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll t1,t2,a1,a2,b1,b2; cin >>t1>>t2>>a1>>a2>>b1>>b2; ll p,q; p=(a1-b1)*t1; q=(a2-b2)*t2; if(p>0){ p=-p; q=-q; } if(p+q<0){ cout << 0 << endl; }else if(p+q==0){ cout << "in...
#include <bits/stdc++.h> #define ll long long using namespace std; ll t1,t2,a1,b1,a2,b2; int main() { scanf("%lld%lld%lld%lld%lld%lld",&t1,&t2,&a1,&a2,&b1,&b2); if(a1*t1+a2*t2==b1*t1+b2*t2) printf("infinity\n"); else { if(a1>b1) swap(a1,b1),swap(a2,b2); if(a1*t1+a2*t2<b1*t1+b2*t2) printf("0\n"); else { ll x...
#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(){ ll t1,t2,a1,a2,b1,b2; cin>>t1>>t2>>a1>>a2>>b1>>b2; a1*=t1; b1*=t1; a2*=t2; b2*=t2; if(a1+a2<b1+b2){ swap(a1,b1); swap(a2,b2); ...
#include<bits/stdc++.h> using namespace std; using Lint=long long; int main() { Lint t[2],a[2],b[2]; cin>>t[0]>>t[1]>>a[0]>>a[1]>>b[0]>>b[1]; Lint X=(a[0]-b[0])*t[0]; Lint Y=(a[1]-b[1])*t[1]; if(X+Y==0){ cout<<"infinity"<<endl; return 0; } if(X+Y<0) X=-X,Y=-Y; if(X>0...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MOD = 1e9+7; const int N = 100001; int main () { ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; ll a = t1*(a1-b1), b = t2*(a2-b2); if (a > 0) a *= -1LL, b *= -1LL; if (a+b < 0) { cout << 0 << endl; } else if (...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; int main(){ lint t1,t2,a1,a2,b1,b2; scanf("%lld%lld%lld%lld%lld%lld",&t1,&t2,&a1,&a2,&b1,&b2); if(a1<b1){ swap(a1,b1); swap(a2,b2); } lint d=(a1-b1)*t1+(a2-b2)*t2; if (d> 0) return puts("0"),0;...
#include <bits/stdc++.h> using namespace std; int main() { long long t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; long long p = (a1 - b1) * t1, q = (a2 - b2) * t2; if (p > 0) { p *= -1; q *= -1; } if (p + q < 0) cout << 0 << endl; else if (p + q == 0) c...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(int argc, const char *argv[]) { ll t1, t2; cin >> t1 >> t2; ll a1, a2, b1, b2; cin >> a1 >> a2 >> b1 >> b2; ll p = (a1 - b1) * t1; ll q = (a2 - b2) * t2; if (p > 0) { p *= -1; q *= -1; } if (p + q < 0) { cout...
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int main() { ll t1, t2; ll a1, a2; ll b1, b2; cin>>t1>>t2>>a1>>a2>>b1>>b2; a1 *= t1; a2 *= t2; b1 *= t1; b2 *= t2; ll p = a1 - b1; ll q = a2 - b2; if(p<0)p = -p,q = -q; ll pq = p+q; ...
#include<bits/stdc++.h> using namespace std; using i64 = int64_t; int main(){ i64 t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; i64 p = (a1 - b1)*t1, q = (a2 - b2)*t2; if(p > 0){ p *= -1; q *= -1; } if(p+q < 0)cout << 0 << endl; else if(p+q == 0)cout << "...
#include <bits//stdc++.h> using namespace std; typedef long long int ll; int main(void) { ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; ll p = (a1 - b1) * t1, q = (a2 - b2) * t2; if (p >= 0) p *= -1, q *= -1; if (p + q < 0) cout << 0 << endl; else if (p + q == 0) cout << "infin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double D; typedef pair<ll,ll> P; #define M 1000000007 #define F first #define S second #define PB push_back #define INF 100000000000000000 ll a,b,c,d,e,f,x,y; int main(void){ cin>>a>>b>>c>>d>>e>>f; x=(c-e)*a; y=(d-f)*b; if(x<0)x...
#include <cstdio> #include <algorithm> using namespace std; int main() { long long int T, t, A, a, B, b; scanf("%lld %lld %lld %lld %lld %lld", &T, &t, &A, &a, &B, &b); if (T * A + t * a == T * B + t * b) printf("infinity"); else { if (A < B) { swap(A, B); swap(a, b); } if (T * A + t * a > T * B + t * b...
#include <bits/stdc++.h> using namespace std; int main(){ long long T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; if(T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2){ cout << "infinity" << endl; return 0; } long long D = T1 * A1 + T2 * A2 - (T1 * B1 + T2 * B2); // 1周期の差 long long M = T1 * A1 - T1 *...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; ll P = T1*(A1-B1); ll Q = T2*(A2-B2); if(P+Q==0){ cout << "infinity" << endl; return 0; } else if(P+Q<0){ swap(A1, B1); ...
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; int P = (A1 - B1) * T1, Q = (A2 - B2) * T2; if (P > 0) { P *= -1; Q *= -1; } if (P + Q < 0) { cout << 0 << endl; } else if (P + Q == 0) {...
#include<iostream> #include<cmath> using namespace std; int main() { long T1, T2; long A1, A2, B1, B2; cin>>T1>>T2; cin>>A1>>A2; cin>>B1>>B2; if((A1-B1)*T1+(A2-B2)*T2==0) cout<<"infinity"<<endl; else if(((A1-B1)*T1>0 & (A1-B1)*T1+(A2-B2)*T2>0) | ((A1-B1)*T1<0 & (A1-B1)*T1+(A2-B2)*T2<0))cout...
// In God We Trust # include <bits/stdc++.h> using namespace std; # define INF 1 << 31 - 1 # define pb push_back # define fi first # define se second # define int long long signed main(){ int t1, t2; cin >> t1 >> t2; int a1, a2; cin >> a1 >> a2; int b1, b2; cin >> b1 >> b2; int a, b; a = t1 * abs(a...
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; using ll = long long; int main(){ ios_base::sync_with_stdio(false); ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; ll a3 = a1 * t1 + a2 * t2; ll b3 = b1 * t1 + b2 * t2; if(a3 == b3){ cout << ...
#include <bits/stdc++.h> int main() { using namespace std; unsigned long T_1, T_2, A_1, A_2, B_1, B_2; cin >> T_1 >> T_2 >> A_1 >> A_2 >> B_1 >> B_2; if(A_1 < B_1){ swap(A_1, B_1); swap(A_2, B_2); } A_1 *= T_1; A_2 *= T_2; B_1 *= T_1; B_2 *= T_2; auto t_1 = A_1 -...
#include<bits/stdc++.h> using namespace std; using Lint=long long; int main() { Lint t[2],a[2],b[2]; cin>>t[0]>>t[1]>>a[0]>>a[1]>>b[0]>>b[1]; Lint X=(a[0]-b[0])*t[0]; Lint Y=(a[1]-b[1])*t[1]; if(X>0) X=-X,Y=-Y; if(X+Y<0) cout<<0<<endl; else if(X+Y==0) cout<<"infinity"<<endl; else{ ...
#include <iostream> using namespace std; int main() { long long t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; long long d1 = a1 * t1 + a2 * t2, d2 = b1 * t1 + b2 * t2, denom = d1 - d2, numer = b1 * t1 - a1 * t1; if (denom == 0) cout << "infinity\n"; else { if (denom < ...
#include <stdio.h> long long t[2], a[2], b[2]; long long w, x, y, z, e, f; long long ans; int main() { scanf("%lld%lld", t, t + 1); scanf("%lld%lld", a, a + 1); scanf("%lld%lld", b, b + 1); if (t[0] * a[0] + t[1] * a[1] == t[0] * b[0] + t[1] * b[1]) { printf("infinity\n"); return 0; } x = t[0]; y = t[1]; if ...
#include <bits/stdc++.h> using ll = long long; using namespace std; int main() { int t1, t2; ll a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; ll d1 = t1 * (a1 - b1); ll d2 = d1 + t2 * (a2 - b2); if ((d1 > 0 && d2 > 0) || (d1 < 0 && d2 < 0)) { cout << 0 << endl; } else if...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { cin.tie(0); ios::sync_with_stdio(false); ll t1, a1, b1, t2, a2, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; a1 *= t1; a2 *= t2; b1 *= t1; b2 *= t2; a2 += a1; b2 += b1; if (a2 == b2) { ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll t1,t2,a1,a2,b1,b2; int main() { scanf("%lld%lld%lld%lld%lld%lld",&t1,&t2,&a1,&a2,&b1,&b2); ll p=(a1-b1)*t1,q=(a2-b2)*t2; if(p>0) p*=-1,q*=-1; if(p+q<0){cout<<0;return 0;} if(p+q==0){cout<<"infinity";return 0;} ll k=-p/(p+q); ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; int main() { ll T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; if (T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2) { cout << "infinity" << endl; return 0; } if (A1 > B1) { swap(A1, B1); s...
#include <bits/stdc++.h> #define rep(i, n) for(int (i) = 0; i < (n); ++(i)) typedef long long ll; const ll MOD = 1e9 + 7; int main() { ll T1, T2, A1, A2, B1, B2; std::cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; ll P, Q; P = T1 * (A1 - B1); Q = T2 * (A2 - B2); if(P > 0) { P = -P; Q = -Q; } if(P...
#include <bits/stdc++.h> using namespace std; int main() { // your code goes here long long s,t,a,b,c,d,i,j,l,r,m; cin >> s >> t >> a >> c >> b >> d; if(s*a+t*c==s*b+t*d){ cout << "infinity" << endl; return 0; } if(a<b){ swap(a,b); swap(c,d); } if(a>b&&c>d){ cout << "0" << endl; return 0; } l=s*(a...
#include<bits/stdc++.h> using namespace std; using ll=long long; int main(){ ll T1,T2,A1,A2,B1,B2; cin>>T1>>T2>>A1>>A2>>B1>>B2; ll a=T1*(A1-B1),b=T2*(A2-B2); if(a<0){a*=-1;b*=-1;} if(a+b>0){cout<<"0"<<endl;return 0;} if(a+b==0){cout<<"infinity"<<endl;return 0;} ll dp=a,ans=0; if(a%(a+b)==0){cout<<-2*(a/...
#include <bits/stdc++.h> using namespace std; long long t1, t2, a1, a2, b1, b2; int main() { cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) { cout << "infinity\n"; return 0; } if (t1 * a1 + t2 * a2 < t1 * b1 + t2 * b2) { swap(a1, b1); sw...
#include <bits/stdc++.h> using namespace std; using ll=long long; #define MOD 1000000007 #define INF 800000000 #define MAX 1000 int main(){ ll T1,T2,A1,A2,B1,B2; cin>>T1>>T2>>A1>>A2>>B1>>B2; if(T1*A1+T2*A2==T1*B1+T2*B2){ cout<<"infinity"<<endl; }else{ ll dx1=T1*B1-T1*A1; ll dx2=T1*B1+T2*B2-T1*A1-T2...
#include<bits/stdc++.h> using namespace std; using Lint=long long; Lint solve(Lint X,Lint Y) { if(X<0) X=-X,Y=-Y; if(X==0) return 1; else{ if(X+Y>0) return 0; else{ Lint res=(X/abs(X+Y)+1)*2-1; if(X%abs(X+Y)==0) res--; return res; } } } int ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ int t1, t2; ll a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; ll ab1 = (a1 - b1)*t1; ll ab2 = (a2 - b2)*t2; if(ab1+ab2 == 0){ cout << "infinity" << endl; return 0; } if((ab1>0 && ab1+ab2>0) || (ab1<0 && ab...
#include<iostream> #include<cstdio> #include<queue> #include<vector> #include<string.h> #include<algorithm> #include<map> using namespace std; long long T1,T2,A1,A2,B1,B2,i,j,k,l,n1,n2,m; int main() { cin >> T1>>T2>>A1>>A2>>B1>>B2; if(A1<B1) { i=B1; B1=A1; A1=i; i=B2; B2=A2; A2=i;...
#include <bits/stdc++.h> using namespace std; int main() { long long T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; long long A = A1 - B1, B = A2 - B2; if(A < 0) { A = -A; B = -B;} if(A * T1 + B * T2 > 0) { cout << 0 << endl; } else if(A * T1 + B * T2 == 0) { ...
#include <bits/stdc++.h> #include <stdlib.h> using namespace std; typedef long long ll; const ll mod=1000000007; const ll BIG=1e15; int main(){ ll T1,T2,A1,A2,B1,B2; cin>>T1>>T2>>A1>>A2>>B1>>B2; ll S=T1*(A1-B1)+T2*(A2-B2); ll C=T1*(A1-B1); if(S==0) cout<<"infinity"<<endl; else if(S>0 && C>0) co...
#include <iostream> #include <vector> using namespace std; typedef long long ll; int main() { int t1, t2; cin >> t1 >> t2; ll a1, a2; cin >> a1 >> a2; ll b1, b2; cin >> b1 >> b2; if (a1 > b1) { swap(a1, b1); swap(a2, b2); } ll diff = t1*(a1-b1)+t2*(a2-b2); if (diff == 0) { cout << "in...
#include <bits/stdc++.h> using namespace std; using Int = long long; int main() { Int T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; A1 -= B1; A2 -= B2; if (A1 == 0 || A1 * T1 + A2 * T2 == 0) { cout << "infinity\n"; return 0; } if (A1 * T1 + A2 * T2 < 0) { ...
#include <bits/stdc++.h> #define ll long long #define V vector<long long> #define VV vector<vector<long long>> #define rep(i,n) for(ll (i)=0;(i)<(n);++(i)) using namespace std; int main(){ ll t1,t2; cin>>t1>>t2; ll a1,a2; cin>>a1>>a2; ll b1,b2; cin>>b1>>b2; ll d1=(a1-b1)*t1; ll d2=(a2-b2)*t2; if(d1+d...
#include <bits/stdc++.h> typedef long long ll; #define rep(i,n) for(ll i=0;i<(n);i++) #define sz(x) ll(x.size()) using namespace std; int main() { ll ans=0,t1,t2,a1,a2,b1,b2,p,q,s,t; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; p=(a1-b1)*t1; q=(a2-b2)*t2; if(p>0) { p*=-1; q*=-1; } if(p+q<0) puts("0"); e...
#include <bits/stdc++.h> using namespace std; int main(){ long long T1,T2,A1,A2,B1,B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; if((T1*A1+T2*A2)==(T1*B1+T2*B2)){ cout << "infinity" << endl; return 0; } if((T1*A1+T2*A2)<(T1*B1+T2*B2)){ swap(A1,B1); swap(A2,B2); } long long diff1=T1*(B1-A1); long l...
#include <iostream> #include <algorithm> using namespace std; typedef long long ll; typedef pair<int,int> P; ll t1,t2,a1,a2,b1,b2; int main(){ cin>>t1>>t2>>a1>>a2>>b1>>b2; a1*=t1; a2*=t2; b1*=t1; b2*=t2; if(a1+a2==b1+b2){ cout<<"infinity\n"; return 0; } if(a1<b1^a1+a2>b1+...
#include<iostream> #include<vector> #include<algorithm> #include<string> #include<iomanip> #include<set> #include<queue> using namespace std; int main() { long long t,s,a,b,c,d; cin >> t >> s >> a >> b >> c >> d; a=a-c; // 区間tにおける増加分 b=b-d; // 区間sにおける増加分 if((a>0 and b>0) or (a<0 and b<0)) { cout << 0 << endl;...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1LL<<62 #define inf 1000000007 int main() { ll t1,t2,a1,a2,b1,b2; cin>>t1>>t2>>a1>>a2>>b1>>b2; ll f1=a1-b1;ll f2=a2-b2; if(f1>0&&f2>0||f1<0&&f2<0){ cout << 0; return 0; } f1=abs(f1);f2=abs(f2); ll dx1=t1*f1; ll dx2=t2*f2; if(d...
#include <stdio.h> long long t[2], a[2], b[2]; long long w, x, y, z, e, f; long long ans; int main() { scanf("%lld%lld", t, t + 1); scanf("%lld%lld", a, a + 1); scanf("%lld%lld", b, b + 1); if (a[0] == b[0])printf("wa\n"); if (a[1] == b[1])printf("wa\n"); x = t[0]; y = t[1]; w = b[0] - a[0]; z = b[1] - a[1]; e...
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll t1,t2,a1,a2,b1,b2; int main() { scanf("%lld%lld%lld%lld%lld%lld",&t1,&t2,&a1,&a2,&b1,&b2); ll a=a1-b1,b=a2-b2; if(a<0) a*=-1,b*=-1; ll k=t1*a+t2*b; if(k==0) {printf("infinity\n");return 0;} if(k>0){printf("0\n");return 0;} ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; a1 *= t1; a2 *= t2; b1 *= t1; b2 *= t2; if (a1 + a2 == b1 + b2) { cout << "infinity" << endl; return 0; } if ((a1 < b1 && a1 + a2 < b1 + b2) |...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; ll d1 = A1 - B1, d2 = A2 - B2; ll once = d1 * T1 + d2 * T2; if (once == 0) { cout << "infinity" << endl; return 0; } else if (...
#include <iostream> using namespace std; typedef long long ll; int main() { int t[2]; cin >> t[0] >> t[1]; ll a[2], b[2]; cin >> a[0] >> a[1]; cin >> b[0] >> b[1]; if(a[0] < b[0]) { swap(a[0], b[0]); swap(a[1], b[1]); } ll c[2] = {a[0] - b[0], a[1] - b[1]}; ll d[2] = {c[0] * t[0], c[1] * t[1...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; if (a1 > b1) { swap(a1, b1); swap(a2, b2); } ll p = (a1-b1)*t1; ll q = (a2-b2)*t2; if (p+q < 0) { cout << 0 << endl; r...
// I SELL YOU...! #include<iostream> #include<vector> #include<algorithm> #include<functional> #include<queue> using namespace std; typedef long long ll; typedef pair<ll,ll> P; signed main(){ ll t0,t1,a0,a1,b0,b1; ll cnt=0; ll p1,p0,diff; cin >> t0 >> t1 >> a0 >> a1 >> b0 >> b1; p0 = t0*(a0-b0); p1 = p0 + ...
#include <iostream> using namespace std; int main() { long long T1, T2; cin>>T1>>T2; long long A1, A2; cin>>A1>>A2; long long B1, B2; cin>>B1>>B2; long long X = T1*(A1-B1); long long Y = T2*(A2-B2); if (X<0) X *= -1, Y *= -1; if (X+Y>0) cout<<0<<endl; ...
#include <bits/stdc++.h> #define ROOP(i, N) for(int i=0; i++; i<N) #define RVROOP(i, N) for(int i=N; i--; i>=0) #define INF 1e9 #define MOD 1000000007 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; int main() { ll T1,T2,A1,A2,B1,B2; cin>>T1>>T2>>A1>>A2>>B1>>B2; ll p=(A1-B1)*T1, q=(A2...
#include <bits/stdc++.h> using namespace std; int main() { int64_t a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f; int64_t i=a*(c-e); int64_t j=b*(d-f); if(i+j==0){ cout<<"infinity"<<endl; } else if(i>0 && j>=0){ cout<<0<<endl; } else if(i<0 && j<=0){ cout<<0<<endl; } else{ if(i>0){ i=-...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int64_t t1,t2,a1,a2,b1,b2; cin >> t1>>t2>>a1>>a2>>b1>>b2; a1 -= b1; a2 -= b2; int64_t l1 = a1*t1; int64_t l2 = a2*t2; if(l1+l2 == 0){ cout << "infinity" << endl; } else{ if(l1+l2 < ...
#include <iostream> using namespace std; typedef long long ll; int main() { ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; if(a1 < b1){ swap(a1, b1); swap(a2, b2); } if(t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2){ cout << "infinity" << endl; return 0...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) using ll = long long; int main(){ ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2; cin >> a1 >> a2; cin >> b1 >> b2; ll l1 = a1*t1+a2*t2, l2 = b1*t1+b2*t2; if(l1 == l2) { cout << "infinity" << endl; return 0; ...
#include "bits/stdc++.h" using namespace std; int main() { long long T1, T2; cin >> T1 >> T2; long long A1, A2, B1, B2; cin >> A1 >> A2 >> B1 >> B2; long long X = (A1 - B1)*T1; long long Y = (A2 - B2)*T2; if (X > 0) { X = -1 * X; Y = -1 * Y; } if (0 == (X + Y)) { cout << "infinity" << endl; return 0; ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll t1,t2,a1,a2,b1,b2; cin>>t1>>t2; cin>>a1>>a2;cin>>b1>>b2; ll x=a1*t1+a2*t2,y=b1*t1+b2*t2; if(x==y)cout<<"infinity"<<endl; else if((x>y&&a1<b1)||(x<y&&a1>b1)){ ll t=(a1-b1)*t1; ll d=y-x; if(t%d!=0)cout<<t/d*2+1<<endl; else co...
#include <iostream> #include <cstring> using namespace std; int main() { unsigned long long t1, t2, a1, b1, a2, b2; cin>>t1>>t2>>a1>>a2>>b1>>b2; if (a1*t1+a2*t2 == b1*t1+b2*t2) { cout<<"infinity"<<endl; return 0; } if (a1*t1+a2*t2 < b1*t1+b2*t2) { swap(a1, b1); swap(a2, b2); } if (a1*t1 > b1*t1) { co...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); long long t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; long long x = t1 * (a1 - b1); long long y = t2 * (a2 - b2); if (x + y == 0) { cout << "infinity\n"; ...
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=int(a);i<int(b);i++) typedef long long ll; typedef pair<ll,ll> P; int main(){ ll t1,t2,a1,a2,b1,b2; cin>>t1>>t2>>a1>>a2>>b1>>b2; ll da1=t1*a1,db1=t1*b1,da2=da1+t2*a2,db2=db1+t2*b2; if(da2==db2){ cout<<"infinity"<<endl; ...
#include <iostream> #include <map> using namespace std; int main() { using Int = long long; Int t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; Int d1 = t1 * (b1 - a1); Int d2 = t2 * (b2 - a2); if (d1 + d2 == 0) { cout << "infinity" << endl; retur...
#include <bits/stdc++.h> using namespace std; int main(){ int64_t T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; if(A1 < B1){ swap(A1, B1); swap(A2, B2); } int64_t d1 = T1*(A1-B1); int64_t d2 = T2*(A2-B2); int64_t d = d1 + d2; if(d > 0){ cout <<...
#include <iostream> #include <algorithm> typedef long long ll; using namespace std; int main() { ll T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; if(A1*T1+A2*T2==B1*T1+B2*T2){ cout << "infinity" << endl; return 0; } if(A1*T1+A2*T2>B1*T1+B2*T2){ swap(A1, B1); swap(A2, B2); } if(A1<B1){...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int main() { long long t1, t2, a1, a2, b1, b2, ma, mb; cin >> t1 >> t2; cin >> a1 >> a2; cin >> b1 >> b2; if (a1 < b1) { swap(a1, b1); swap(a2, b2); } ma = a1 * t1 + a2 * t2; mb = b1 * t1 + b2 * t2; if (ma == mb) { co...
#include <bits/stdc++.h> using namespace std; int main() { long long T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; long long x = T1 * (A1-B1); long long y = T2 * (A2-B2) + x; if (y == 0) { cout << "infinity" << endl; return 0; } if (y < 0) { x = -x; y = -y; } if (x >= 0) { cout << ...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (int)(n); ++i) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) int main() { int mod=1000000007; long t1,t2,a1,a2,b1,b2; cin >> t1>>t2>>a1>>a2>>b1>>b2; long k=t1*a1; long m=t1*b1; long l=k+t2*a2; long n=m+t2*b2; ...
// F. #include <iostream> #include <sstream> #include <algorithm> #include <vector> using namespace std; typedef long long LL; int main(int argc, char* argv[]) { cout.precision(20); #ifdef _MSC_VER while (true) #endif { LL t1 = -1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2; if (t1 < 0) re...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int t1,t2; ll a1,b1,a2,b2; cin>>t1>>t2; cin>>a1>>a2>>b1>>b2; if(a1<b1) swap(a1,b1),swap(a2,b2); ll s1=t1*a1+t2*a2; ll s2=t1*b1+t2*b2; if(s1==s2){ printf("infinity\n"); return 0; } i...
#include<bits/stdc++.h> using namespace std; using ll=long long; int main(){ int t1,t2; ll a1,a2,b1,b2; cin >> t1 >> t2; cin >> a1 >> a2; cin >> b1 >> b2; a1=a1*t1; a2=a2*t2; b1=b1*t1; b2=b2*t2; if(a1+a2<b1+b2){ swap(a1,b1); swap(a2,b2); } if(a1+a2==b1+b2){ cout << "infinity" << en...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll T1, T2; ll A1, A2; ll B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; A1 *= T1; A2 *= T2; B1 *= T1; B2 *= T2; if (A1 + A2 == B1 + B2) { cout << "infinity" << endl; return 0; } if (A1 < B1 && A1 + A2 < B1 + B2) { cout ...
#include <cstdio> #include <algorithm> using namespace std; long long t1,t2; long long a1,a2; long long b1,b2; int main(){ scanf("%lld%lld%lld%lld%lld%lld",&t1,&t2,&a1,&a2,&b1,&b2); if (t1*a1+t2*a2==t1*b1+t2*b2){ printf("infinity\n"); return 0; } if (t1*a1+t2*a2<t1*b1+t2*b2){ ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int main(){ ll T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2; ll alpha = T1*(A1-B1) + T2*(A2-B2); ll beta = T2*(A2-B2); if(alpha == 0){ cout << "infinity" << endl; }else{ ...
#include<bits/stdc++.h> using namespace std; int main(){ long long t1,t2,a1,a2,b1,b2;cin>>t1>>t2>>a1>>a2>>b1>>b2; long long x = a1*t1+a2*t2,y=b1*t1+b2*t2; if(x==y){ cout<<"infinity"<<endl; return 0; } //long long r = t1*a1-t1*b1; if((x>y&&a1<b1)||(x<y&&a1>b1)){ long ...