#include <iostream> using namespace std; int main() { int n; int Break=0; long long int res,res1,res2,res3,res4,rank,diff; long long int b_left,b_ryt,t_left,t_ryt; while(cin>>n) { res=1; res1=1; res2=1; res3=1; res4=1; Break=0; if(n==1) { cout<<7<<";"<<8<<";"<<9<<";\n"; cout<<6<<";"<<1<<";"<<2<<";\n"; cout<<5<<";"<<4<<";"<<3<<";\n"; continue; } for(long long int i=0;i<1500000000;i++) { if(Break) break; res1+=i*2; if(res1>=n) { rank=i; res=res1; Break=1; //continue; } res2+=i*4; if(res2>=n) { rank=i; res=res2;
993
Solution: #include <iostream> #include <vector> using namespace std; int main() { int t,c; long long int n; vector<long long int> v; cin>>t; while(t–) { cin>>n; if(n<=9) { cout<<n<<"\n"; continue; } while(n>=10) { v.clear(); c=0; for(long long int i=9;i>=2;i–) { if(n%i==0) { c=1; n/=i; v.push_back(i); break; } } if(n<10) { v.push_back(n); break; } if(c==0) { v.clear();
991
Theory: For larger n, imagine choosing an arbitrary pair of people to shake hands. You’ve now divided the circle into two smaller circles (one of which may have 0 people in it). The number of ways you can arrange the rest of the people is the product of the answers for the two smaller circles.
960
Gaussian Prime Integer Problem Theory: First we should know that the multiple of two lengths is the length of the original one. For example, (4,3) has a length of 5, so if we can break (4,3) down into A & B, length(A) * length(B) is also 5. Next we’ll iterate through all possible combinations (lengths.)
10179
Euler function (Phi) Problem How to Solve: if n is prime then number of relative prime from 1 upto n is n-1. This is represented as phi function. if n and m relatively prime then phi(mn)=phi(n)*phi(m). (proof given bellow as matrix representation of the 1 from mn) The problem was solved by taking the number
