846

#include <iostream> #include <math.h> using namespace std; //long long diff[10001]; long long int m,n,d; int main() { int t; cin>>t; while(t–) { cin>>m>>n; d= m-n; if(d<0) d=d*(-1); if(d==0) { cout<<0<<"\n"; continue; } if(d==1) { cout<<1<<"\n"; continue; } if(d==2) { cout<<2<<"\n"; continue; } if(d==3) { cout<<3<<"\n"; continue; } long long int r= sqrt(d); if(r<0) r*=-1; if(d==r*r)

10023

[highlight]Solution[/highlight] /* import java.math.BigInteger; import java.util.Scanner; public class Main {public static void main(String[] args) { Scanner scanf = new Scanner(System.in); int time; time = scanf.nextInt(); System.out.println(""); for(int i = 0; i<time; i++){ BigInteger input = scanf.nextBigInteger(); if(i > 0) System.out.println(""); BigInteger previous = input; BigInteger distance, post, Two = BigInteger.valueOf(2), Negative = BigInteger.valueOf(-1); if(input.equals(BigInteger.ZERO)){ System.out.println("0");

10002

[highlight]Solution:[/highlight] Centroid of polygon The centroid of a non-self-intersecting closed polygon defined by n vertices (x0,y0), (x1,y1), …, (xn−1,yn−1) is the point (Cx, Cy), where Cx= 1/6A *sumof((X_i+X_i+1)*(X_i*Y_i+1 – X_i+1 * Y_i)); fori=0 to n-1 Cy= 1/6A *sumof((Y_i+Y_i+1)*(X_i*Y_i+1 – X_i+1 * Y_i));for i=0 to n-1 and where A is the polygon’s signed area, A =

10025

#include <iostream> using namespace std; unsigned long long int T[60001]; int main() { int t,n,c=0; int r,pos; T[1]=1; for(int i=2;i<60001;i++) T[i]=T[i-1]+i; //cout<<T[60000]<<"\n"; cin>>t; c=t; int k=0; while(t–) { cin>>n; if(k!=c &&k!=0) cout<<"\n"; k++; if(n==0) { cout<<3<<"\n"; continue; } if(n==1) { cout<<2<<"\n"; continue; } if(n<0) n*=-1; for(int i=1;i<60001;i++) { if(T[i]>=n) { r= T[i]; pos=i; break; }

10015

#include <iostream> #include <vector> #include <stdio.h> using namespace std; int prime[40001]; vector<int> vb,v; int _p(int n) { int pos=0; v.clear(); for(int i=1;i<=n;i++) v.push_back(i); for(int i=0;i<n-1;i++) { int k=vb[i]; int l = k%v.size()-1; if(l+pos>(v.size()-1)) { pos=l+pos-v.size(); } else pos = l+pos; v.erase(v.begin()+pos); } cout<<v[0]<<"\n"; v.clear(); return 0; } int main() { int n; for(int i=2;i*i<40000;i++) {

11762

#include <iostream> #include <vector> #include <map> #include <stdio.h> using namespace std; int prime[1000001]; int primes[1000001]; double dp[1000001]; vector<int> vb; map<int,int> mp; int main() { int n,t; primes[0]=primes[1]=0; for(int i=2;i*i<1000001;i++) { if(prime[i]==0) { for(int j=i*i;j<1000001;j+=i) { prime[j]=1; primes[j]=i; } //primes[i]=i; } } prime[0]=prime[1]=0; for(int i=2;i<1000001;i++) { if(primes[i]==0) primes[i]=i; if(prime[i]) prime[i]=0; else prime[i]=1; prime[i]+=prime[i-1]; } dp[1]=0; for(int

11119

#include <iostream> #include <map> #include <stdio.h> #include <string> #include <string.h> #include <vector> #include <algorithm> using namespace std; map<string,int> cat; map<string,int> an; map<int,string> _cat; map<int,string> _an; vector<string> vb[110]; vector<int> vcat,ancat; int pri_cat[110][110]; int pri_an[110][110]; string s[110]; string S1[110],S2[110]; int Nc,Na,mix; struct msr{ int weight; int pos; }pwr[110]; bool cmp(msr a,msr b) { return a.weight>b.weight; } int