Ofstream out("output txt")
Download 61.5 Kb.
|
100ta masala
- Bu sahifa navigatsiya:
- 58-masala include using namespace std; int main () { int a; cin >>a; cout << 7-a; } 59-masala
47-masala
#include #define ll long long using namespace std; string to2(int n) { string r; while (n != 0){ r += ( n % 2 == 0 ? "0" : "1" ); n /= 2; } return r; } int main() { int t;
while(t--){ int n,ans=0; string m; cin>>n; m=to2(n); for(int i=0;i for (int i=1;i<=n;i++) { 49-masala int main() while(t--){ for(ll i=0; i<=10000;i++){ #include }
if (n % 2 == 0) { return 0; int main() { for (int i = 0; i < t; i++) { return 0; int main() { for (int i = 0; i < 39; i++) { std::sort(l.begin(), l.end()); int t;
while (t > 0) { return 0; #include int main() {
long long result = n * (2 * n - 1); std::cout << result << std::endl;
return 0; #include int main() {
long long result = (n * n + n + 2) / 2; std::cout << result << std::endl;
return 0; const ll MOD = 1e9+7; // base^p ll t = bin_pow(base, p/2); // (a/b) mod m int main(){ long long result = n / 2 + 1; cout << result << endl;
return 0; using namespace std; int main() {
vector int k;
sort(a.begin(), a.end());
cout <
return 0;
void dfs(int u, int s) { void add(int u, int v) const long long MOD = 1000000007; long long gcd(long long a, long long b) {
long long fib(long long n) { auto mult = [](const std::vector while (n > 0) { return r[1][0]; int main() { long long result = fib(gcd(a, b)); std::cout << result << std::endl;
return 0; int main() { long long x = (n / 2) + 1; std::cout << x << std::endl;
return 0; int main() { double a = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); if (a + b > c && a + c > b && b + c > a) { return 0; long long Fib_Last_Digit(long long n) { int main() { for (int i = 0; i < t; ++i) { if (n > 60) { std::cout << Fib_Last_Digit(n) << std::endl; return 0; #include using namespace std;
int const mod = 1e9+7; long long binpow(long long a, long long b, long long m){
if(b == 0) return 1; long long k = binpow(a, b / 2, m) % m;
k *= k;
if(b % 2 == 1) return (a * k) % m; return k;
}
long long binpow1(long long a, long long b, long long m) { long long res = 1; while (b > 0) {
if (b & 1) res = res * a % m;
a = a * a % m; b >>= 1;
}
return res; long long cnr(long long a, long long b, long long m){ long long t = 1, d = 1; for(int i = 1; i <= b; i ++){ t = (t * i) % m; d = (d * (a - i + 1)) % m; } return ((d * binpow(t, (m - 2), m))) % m; } int main(){ long long n; cin >> n; long long d = cnr((2 * n), n, mod); d *= binpow1(n + 1, mod - 2, mod); cout << d % mod << endl; return 0; }
75-masala #include #include using namespace std; vector long long inv_count(vector if(l >= r - 1 ) return 0; int m = (l + r) / 2; long long x= inv_count (a , l , m); long long y = inv_count(a , m , r); long long q=0; for(int i= l , j= m ; i < m; i++){ while(j < r && a[i] > a[j]) j++; q+=j - m; } for(int k=l , i=l , j=m; k < r; k++){ helper[k]=a[i==m ? j++ :j == r ? i++:a[i]} for(int i=l ; i < r ; i++) a[i]=helper[i]; return q + x +y; } int main (){ int n; cin>>n; vector for(int i=0 ; i < n ; i++) cin>>a[i]; helper.resize(n); cout< } 78-masala #include #include int main() { int n, k; std::cin >> n >> k; std::vector for (int i = 0; i < n; ++i) { std::cin >> arr[i]; } int s = 0; for (int i = 0; i < n; ++i) { s += arr[i]; if (s - k < 0) { s = 0; } else { s = s - k; } } if (s < 0) { std::cout << 0 << std::endl; } else { std::cout << s << std::endl; } return 0; } 80-masala #include using namespace std; int main(){
int n; long long s = 0; cin >> n; vector for(int &x: a){ cin >> x; s += x; } int inf = s / n; vector for(int i = 1, j; 1LL * i * i <= s; i ++){ if(s % i == 0){ divs.push_back(i); j = s / i; if(i != j && j <= inf) divs.push_back(j); } } sort(divs.rbegin(), divs.rend()); int i = -1, mod, l, r; vector while(true){ mod = divs[++ i]; for(int i = 0; i < 2 * n; i ++) b[i] = a[i] % mod; sort(b.begin(), b.end()); l = 0; r = 2 * n - 1; while(l <= r && b[l] == 0) l ++; if(l % 2 != 0) continue; while(l < r && b[l]+b[r] == mod) l ++, r --; if(l < r) continue; break; } cout << divs[i] << endl; return 0; } 82-masala #include #include int main() { int s, t, a, b, m, n; std::cin >> s >> t >> a >> b >> m >> n; std::vector for (int i = 0; i < m; ++i) { std::cin >> d[i]; } std::vector for (int j = 0; j < n; ++j) { std::cin >> d1[j]; } int x = 0; int y = 0; for (const auto &i : d) { if (i >= (s - a) && i <= (t - a)) { x += 1; } } for (const auto &j : d1) { if (j <= (t - b) && j >= (s - b)) { y += 1; } } std::cout << x << std::endl; std::cout << y << std::endl; return 0; } 83-masala #include #include int main() { int s, t, a, b, m, n; std::cin >> s >> t >> a >> b >> m >> n; std::vector for (int i = 0; i < m; ++i) { std::cin >> d[i]; } std::vector for (int j = 0; j < n; ++j) { std::cin >> d1[j]; } int x = 0; int y = 0; for (const auto &i : d) { if (i >= (s - a) && i <= (t - a)) { x += 1; } } for (const auto &j : d1) { if (j <= (t - b) && j >= (s - b)) { y += 1; } } std::cout << x << std::endl; std::cout << y << std::endl; return 0; } 84-masala #pragma GCC optimize("Ofast") #include using ll = long long; #define vi vector #define vc vector #define pb push_back #define rep(i, a, b) for(ll i = (a); i != (b); i += 2 * ((a) < (b)) - 1) #define all(x) (x).begin(), (x).end() #define endl '\n' #define fast ios::sync_with_stdio(false); cin.tie(0); using namespace std; const int mod = 1e9 + 7; int main(){ fast ll n, m, r; cin >> n >> m >> r; ll a[n][m], b[n][m]; rep(i, 0, n) rep(j, 0, m) cin >> a[i][j]; ll left = 0, right = m - 1, up = 0, down = n - 1; while(left <= right && up <= down){ vi frame; rep(i, up, down) frame.pb(a[i][left]); rep(i, left, right) frame.pb(a[down][i]); rep(i, down, up) frame.pb(a[i][right]); rep(i, right, left) frame.pb(a[up][i]); ll len = frame.size(); ll ind = 0; rep(i, up, down) //frame.pb(a[i][left]); a[i][left] = frame[(ind++ - r % len + len) % len]; rep(i, left, right) //frame.pb(a[down][i]); a[down][i] = frame[(ind++ - r % len + len) % len]; rep(i, down, up) //frame.pb(a[i][right]); a[i][right] = frame[(ind++ - r % len + len) % len]; rep(i, right, left) //frame.pb(a[up][i]); a[up][i] = frame[(ind++ - r % len + len) % len]; left++; right--; up++; down--; } rep(i, 0, n) rep(j, 0, m) cout << a[i][j] << " \n"[j == m - 1]; cout << endl; return 0; } Download 61.5 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling