[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");
Category: Math
10036
Modular Problem: Mod of a negative number ..llike -16%3 = 2 It is DP problem. such input of data is in p[]; divident is k; let , s=a[0]%k; and s=-a[0]%k; if any of s <0 then s =s+k [see mod of a negative number] keep track in 2D array in a[0][s]=1. s=s+p[1]%k, for each s check
10078
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Point{ int x; int y; }P; vector<Point> vb,vb1; int used[100]; bool cmp(Point a,Point b) { if(a.x!=b.x) return a.x<b.x; else return a.y<b.y; } int ccw(Point a,Point b,Point c) { int p = a.x*b.y – a.x*c.y – a.y*b.x + a.y*c.x + b.x*c.y – c.x * b.y; if(p>0)
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; }
10061
[highlight]Solution[/highlight] /* Now we can break the Base B as a product of primes : B = a^p1 * b^p2 * c^p3 * … Then the number of trailing zeroes in N factorial in Base B is given by the formulae min{1/p1(n/a + n/(a*a) + ….), 1/p2(n/b + n/(b*b) + ..), ….}. And the number
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();
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.)