ODDSUM - Editorial

Thanks Will keep this in mind.

May I know how to see blogs of codeforces

Just simply search codeforces blog u will find top results from Google or u can check TOP blogs via top section of codeforces

Guys I am getting a WA for this ,can someone help me pointing out what’s wrong here?

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define vt vector<ll>
#define vvt vector<vt>
#define vvvt vector<vvt>
#define all(c) (c).begin(), (c).end()
#define rep(i, start, end) for(ll i=start; i<=end; i++)
#define sd(n) scanf("%lld",&n)
#define eps 1e-3
const ll mod=1e17+7;
const ll maxs=1e5+5;
#define dbg(x) cout<<"val of var is"<<x;
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define bitc  __builtin_popcountll
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
ll add(ll x,ll y ){ll res=x+y;return (res>=mod?res-mod:res);}
ll sub(ll x,ll y ){ll res=x-y;return (res<=0?res+mod:res);}
ll binpow(long long a, long long b) {a %= mod;long long res = 1;while (b > 0) {if (b & 1)res = res * a % mod;a = a * a % mod;b >>= 1;}return res;}
ll mul(ll x,ll y){ll res=x*y;return(res>=mod?res%mod:res);}
ll inv(ll x){return binpow(x,mod-2);}
template<class T>void print(T &a){for(auto val: a)cout << val << " ";cout << "\n";}
template<class T>ll size(T &a){return a.size();}
template<class T>void read(vector<T> &a){for(ll i=0;i<size(a);i++)cin>>a[i];}
ll ceil2(ll a, ll b) { if (a == 0) return 0;return (a +b-1)/b ;}
inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b) { return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a,ll b){return (b==0 or a==0) ? 0:mul(mul(a,b),inv(gcd(a,b)));}
ll 	pow2(int i) 		{ return 1LL << i; }
int topbit(signed t) 	{ return t == 0 ? -1 : 31 - __builtin_clz(t); }
int topbit(ll t) 		{ return t == 0 ? -1 : 63 - __builtin_clzll(t); }
int lowbit(signed a) 	{ return a == 0 ? 32 : __builtin_ctz(a); }
int lowbit(ll a) 		{ return a == 0 ? 64 : __builtin_ctzll(a); }
ll  allbit(ll n) 		{ return (1LL << n) - 1; }
int popcount(signed t) 	{ return __builtin_popcount(t); }
int popcount(ll t) 		{ return __builtin_popcountll(t); }
bool ispow2(int i) 		{ return i && (i & -i) == i; }
vt primes(ll n){
  bool prime[n+1];
  vt p;
  fill_n(prime,n+1,true);
    for(int i=2;i*i<=n;i++){
        if(prime[i]==true)
        {
            for(int j=i*i;j<=n;j+=i){
                    prime[j]=false;
            }
        }
    }
    for(int j=2;j<=n;j++){
      if(prime[j])
         p.pb(j);
    }
    return p;
}
vt prime_factors(ll n){
  vt p;
  for(ll i=2;i*i<=n;i++){
        while(n%i==0){
        p.pb(i);
        n/=i;
        }
    }
     if(n>1){
        p.push_back(n);
     }
  return p;
}

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
        // Update y and x
        y = x - q * y;
        x = t;
    }
    // Make x positive
    if (x < 0)
       x += m0;
    return x;
}
ll fact[200010];

void compute_fact(ll modVal) {
  fact[0]=1;
  for(int i=1;i<=200004;i++) {
    fact[i]=(fact[i-1]*i)%modVal;
  }
}

ll ncr_mod(ll n,ll r,ll modVal) {
  if(r==0||n==r) return 1;
  if(n<r) return 0;
  return (((fact[n]*modInverse(fact[r],modVal))%modVal)*modInverse(fact[n-r],modVal))%modVal;
}

#define lim 400009
void solve(){
  int n;
  cin>>n;
  cout<<(n-1)*(n-2)+1<<"\n";
} 
int main(){
    fast;
	int t;
	cin>>t;
	while(t--){
		solve();
	}
return 0;
}

Yet another reminder :stuck_out_tongue:

@ssjgz

Daam long long!! Thanks buddy.

1 Like

can someone plz help me why am I getting WA?
https://www.codechef.com/viewsolution/53120347

Consider the test input:

1
1000000000

Hey @iceknight1093 I am using the fastest I/O Operation for Java (according to the GFG Article) but still my code is getting TLE.

Please Help.

Link to my submission :-
https://www.codechef.com/viewsolution/63921482

Link to GFG Article that I reffered to :-

(I used method 4)

Hey @rahulahuja2901 :wave: ,
Your code is giving TLE is for the reason I/O. I have changed your code with the another fast I/O technique and it gives AC. here is the technique I used.