1878C - Vasilije in Cacak - CodeForces Solution


math

Please click on ads to support us..

C++ Code:

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
 #pragma GCC optimize("unroll-loops")
 #include <bits/stdc++.h>
 #include <complex>
 #include <queue>
 #include <set>
 #include <unordered_set>
 #include <list>
 #include <chrono>
 #include <random>
 #include <iostream>
 #include <algorithm>
 #include <cmath>
 #include <string>
 #include <vector>
 #include <map>
 #include <unordered_map>
 #include <stack>
 #include <iomanip>
 #include <fstream>
 #include <bitset>
 #include <numeric>
 using namespace std;
 using std::cout;
 using std::endl;
 using std::string;
 using std::bitset;
 typedef unsigned long long ull;
 typedef long long ll;
 typedef long double ld;
 typedef pair<int,int> p32;
 typedef pair<ll,ll> p64;
 typedef pair<double,double> pdd;
 typedef vector<ll> v64;
 typedef vector<int> v32;
 typedef vector<vector<int> > vv32;
 typedef vector<vector<ll> > vv64;
 typedef vector<vector<p64> > vvp64;
 typedef vector<p64> vp64;
 typedef vector<p32> vp32;
 ll MOD = 1000000007;
 double eps = 1e-12;
 #define forn(i,e) for(ll i = 0; i < e; i++)
 #define forsn(i,s,e) for(ll i = s; i < e; i++)
 #define rforn(i,s) for(ll i = s; i >= 0; i--)
 #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
 #define forr(it,t) for(ll it=1;it<=t;it++)
 #define dbg(x) cout<<#x<<" = "<<x<<ln
 #define mp make_pair
 #define pb push_back
 #define fi first
 #define se second
 #define INF 2e18
 #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 #define all(x) (x).begin(), (x).end()
 #define al(arr,n)arr,arr+n
 #define sz(x) ((ll)(x).size())


void solve(){

}
int main()
{
fast_cin();
ll t;
cin >> t;
while(t--){
long long n,k,s;
cin>>n>>k>>s;
long long sm=0,sm1=0,sm2=0;
sm = (n*(n+1))/2;
sm1 = (k*(k+1))/2;
int x=n;
for(int i=0; i<k; i++){
    sm2 += x;
    x--;
}
//if(s%2!=0 && k%2==0) cout<<"NO"<<endl;
if(sm<s || sm1>s) cout<<"NO"<<endl;
else if(sm2<s) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}


Comments

Submit
0 Comments
More Questions

292B - Network Topology
1339A - Filling Diamonds
910A - The Way to Home
617A - Elephant
48A - Rock-paper-scissors
294A - Shaass and Oskols
1213A - Chips Moving
490A - Team Olympiad
233A - Perfect Permutation
1360A - Minimal Square
467A - George and Accommodation
893C - Rumor
227B - Effective Approach
1534B - Histogram Ugliness
1611B - Team Composition Programmers and Mathematicians
110A - Nearly Lucky Number
1220B - Multiplication Table
1644A - Doors and Keys
1644B - Anti-Fibonacci Permutation
1610A - Anti Light's Cell Guessing
349B - Color the Fence
144A - Arrival of the General
1106A - Lunar New Year and Cross Counting
58A - Chat room
230A - Dragons
200B - Drinks
13A - Numbers
129A - Cookies
1367B - Even Array
136A - Presents