├── A Real Opportunity.cpp ├── README.md └── Save Me From Assignments.cpp /A Real Opportunity.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | typedef long double ld; 5 | const ll INF = 9223372036854775807; 6 | const ll MOD = 1000000007; 7 | const long double PI = acos(-1); 8 | #define pb push_back 9 | #define mp make_pair 10 | #define all(v) v.begin(), v.end() 11 | #define o0(a) cout<>a 17 | #define i2(a, b) cin>>a>>b 18 | #define i3(a, b, c) cin>>a>>b>>c 19 | #define i4(a, b, c, d) cin>>a>>b>>c>>d 20 | #define fi first 21 | #define se second 22 | 23 | inline ll power(ll a, ll b, ll z = MOD) 24 | { 25 | ll res = 1; 26 | a = (a%z); 27 | while(b) 28 | { 29 | if(b&1) 30 | res = (res*a)%z; 31 | a = (a*a)%z; 32 | b = b>>1; 33 | } 34 | return res; 35 | } 36 | 37 | inline ll inverse(ll a, ll z = MOD) 38 | { 39 | return power(a, z-2, z); 40 | } 41 | 42 | ll extend(ll a, ll b, ll &x, ll &y) 43 | { 44 | if(b == 0) 45 | { 46 | x = 1; 47 | y = 0; 48 | return a; 49 | } 50 | ll x1, y1; 51 | ll g = extend(b, a%b, x1, y1); 52 | x = y1; 53 | y = x1- (a/b)*y1; 54 | return g; 55 | } 56 | 57 | class matrix 58 | { 59 | public: 60 | ll n, aray[5][5], z = MOD; 61 | matrix(ll n) 62 | { 63 | this->n = n; 64 | for(ll i=0;i>1; 105 | } 106 | return ans; 107 | } 108 | 109 | // void build(ll node, ll l, ll r) 110 | // { 111 | // lazy[node] = 0; 112 | // if(l == r) 113 | // { 114 | // tree[node] = aray[l]; 115 | // return ; 116 | // } 117 | // ll mid = (l+r)>>1; 118 | // build(node<<1, l, mid); 119 | // build((node<<1)+1, mid+1, r); 120 | // tree[node] = tree[node<<1] + tree[(node<<1)+1]; 121 | // return ; 122 | // } 123 | 124 | // void update(ll node, ll l, ll r, ll left, ll right, ll val) 125 | // { 126 | // if(lazy[node] != 0) 127 | // { 128 | // tree[node] += (r-l+1)*lazy[node]; 129 | // if(l != r) 130 | // { 131 | // lazy[node<<1] += lazy[node]; 132 | // lazy[(node<<1)+1] += lazy[node]; 133 | // } 134 | // lazy[node] = 0; 135 | // } 136 | // if(left > r || l > right) 137 | // return ; 138 | // if(left <= l && right >= r) 139 | // { 140 | // tree[node] += val*(r-l+1); 141 | // if(l != r) 142 | // { 143 | // lazy[node<<1] += val; 144 | // lazy[(node<<1)+1] += val; 145 | // } 146 | // return ; 147 | // } 148 | // ll mid = (l+r)>>1; 149 | // update(node<<1, l, mid, left, right, val); 150 | // update((node<<1)+1, mid+1, r, left, right, val); 151 | // tree[node] = tree[node<<1] + tree[(node<<1)+1]; 152 | // return ; 153 | // } 154 | 155 | // ll query(ll node, ll l, ll r, ll left, ll right) 156 | // { 157 | // if(left > r || l > right) 158 | // return 0; 159 | // if(lazy[node] != 0) 160 | // { 161 | // tree[node] += (r-l+1)*lazy[node]; 162 | // if(l != r) 163 | // { 164 | // lazy[node<<1] += lazy[node]; 165 | // lazy[(node<<1)+1] += lazy[node]; 166 | // } 167 | // lazy[node] = 0; 168 | // } 169 | // if(left <= l && right >= r) 170 | // return tree[node]; 171 | // ll mid = (l+r)>>1; 172 | // return query(node<<1, l, mid, left, right) + query((node<<1)+1, mid+1, r, left, right); 173 | // } 174 | 175 | int main() 176 | { 177 | ios_base::sync_with_stdio(false); 178 | cin.tie(NULL); 179 | ll n, m; 180 | cin>>n>>m; 181 | n = n%m; 182 | ll x = 1, low = n%m, y = 1, high = n%m, curr = 1; 183 | for(int i=1;i<=m;i++) 184 | { 185 | curr = (curr*n)%m; 186 | if(curr > high) 187 | { 188 | high = curr; 189 | y = i; 190 | } 191 | if(curr < low) 192 | { 193 | low = curr; 194 | x = i; 195 | } 196 | } 197 | cout< 2 | using namespace std; 3 | #define ld long double 4 | 5 | const ld a = 0.0000001; 6 | ld aray[10000]; 7 | int n, k; 8 | 9 | bool poss(double val) 10 | { 11 | int c = 0; 12 | for(auto x : aray) 13 | { 14 | c += floor(x/val); 15 | if(c >= k) 16 | return true; 17 | } 18 | if(c >= k) 19 | return true; 20 | return false; 21 | } 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cin>>n>>k; 27 | for(int i=0;i>aray[i]; 29 | ld left = 0, right = 1e9, mid; 30 | while(left+a < right) 31 | { 32 | mid = (left+right)/2; 33 | if(poss(mid)) 34 | left = mid; 35 | else 36 | right = mid; 37 | } 38 | cout<