Ofstream out("output txt")
Download 61.5 Kb.
|
100ta masala
94-masala
#include using namespace std; #define ll long long #define int long long signed main(){ int n, m,k; cin >> n; m=n; int matrix[n][n]; for(int i = 0; i cin >> matrix[i][j];
}
#include #define int long long using namespace std; const int V = ((1 << 10) - 1); void P(vector int>& freq) {
for (int i = 0; i for (int j = 0; j < v[i].size(); j++) T.insert(v[i][j] - '0');
int digit = (*it); mask += (1 << digit);
}
}
}
int ans = 0; for (int i = 1; i <= 1023; i++) { for (int j = 1; j <= 1023; j++) { if ((i | j) == V) { if (i == j) ans += (freq[i] * (freq[i] - 1)); else
ans += (freq[i] * freq[j]); } } } return ans/2; } int C(vector { map P(v, freq); return S(freq); }
{ int n;
string str; cin>>n;
vector for(int i=0;i cin>>str;
v.push_back(str); }
cout << C(v) << endl; }
#include #include #include #include using namespace std; #define GET_MACRO(_1, _2, _3, NAME, ...) NAME #define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define _rep(i,n) _repl(i,0,n) #define rep(...) GET_MACRO(VA_ARGS, _repl, _rep)(VA_ARGS) #define mp(a,b) make_pair((a),(b)) #define pb(a) push_back((a)) #define all(x) (x).begin(),(x).end() #define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x)) #define fi first #define se second #define dbg(...) _dbg(#__VA_ARGS__, VA_ARGS) void _dbg(string){cout< template #define MOD 1000000007 #define long long long template class BIT { private: vector int n; public: BIT(int _n) : n(_n) { bit = vector } void add(int v, T a) { for(int x=v+1; x<=n; x += x&(-x)) bit[x] += a; } T sum(int v) { T ret=0; for(int x=v+1; x>0; x -= x&(-x)) ret += bit[x]; return ret; } }; int a[300005]; bool appear[300005]; long fact[300005]; int main() { int n; scanf("%d", &n); rep(i,n) scanf("%d", a+i); fill(appear, appear+n+1, false); rep(i,n) appear[a[i]] = true; vector rep(i,1,n+1) if(!appear[i]) b.pb(i); fact[0] = 1; rep(i,n) fact[i+1] = (i+1)*fact[i] %MOD; long m = b.size(); long sumb = 0; for(auto x : b) sumb += x-1; sumb %= MOD; BIT long ans = fact[m]; long k = 0; long pre = 0; rep(i,n) { if(a[i]==0) { long tmp = sumb * fact[m-1] %MOD - pre * fact[m-1] %MOD - ((m>=2) ? (m*(m-1)/2 %MOD * fact[m-2] %MOD * k %MOD) : (0)); ans = (ans + tmp*fact[n-i-1]) %MOD; k++; } else { long tmp = (a[i]-1) * fact[m] %MOD - bit.sum(a[i]) * fact[m] %MOD - ((m>=1) ? ((long)(lower_bound(all(b), a[i]) - b.begin()) * k %MOD * fact[m-1] %MOD) : (0)); ans = (ans + tmp*fact[n-i-1]) %MOD; bit.add(a[i], 1); pre = (pre + b.end() - lower_bound(all(b), a[i])) %MOD; } } ans %= MOD; if(ans < 0) ans += MOD; cout << ans << '\n'; return 0; } 97-masala #include using namespace std; int main() {
long long i = 1; while (true) { if ((a & i) == (b & i)) { cout << i << endl; break; } i = i * 2; } return 0; } 98-masala #include using namespace std; int main() {
long long k = 0; while (n > 1) { if (n % 3 == 0) { n = n / 3; k += 1; } else if (n % 3 == 1 &&n != 1) { n = 2 * n + 1; k += 1; } else { n = 2 * n - 1; k += 1; } } cout << k << endl; return 0;
using namespace std; int main() {
if (n == 2 || n == 3) { cout << 2 << endl; } else if (n == 1) { cout << 1 << endl; } else { long long i = 1; while (i <= sqrt(n + 1)) { if ((n + 1) % i == 0) { a += 1; } i += 1; } if (a >= 2) { cout << 0 << endl; } else { cout << n << endl; } } return 0; } 100-masala #include using namespace std; string uzinlik(long long x1, long long x2, long long x4, long long y1, long long y2, long long y4) {
if (a == b) { return "YES"; } else { return "NO"; } } int main() { int t; cin >> t; for (int i = 0; i < t; ++i) { long long x1, x2, x3, x4, y1, y2, y3, y4; cin >> x1 >> x2 >> x3 >> x4; cin >> y1 >> y2 >> y3 >> y4; cout < return 0; Download 61.5 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling