CF1151div2(Round 553)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CF1151div2(Round 553)相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/space' title='space'>space cpp line time str print f11 鏁板垪 def
CF1151div2(Round 553)
鎬濊矾棰樺ぇ璧?/del>
A
灏戣€冭檻浜嗕竴绉嶆儏鍐?鍒版娌℃兂鍒?/p>
B
璨屼技鎴戦殢鏈哄寲50000娆?娌℃壘鍒板氨鏃犺В璨屼技涔熻繃浜?/p>
鎰熻闅忛殢渚夸究涔辨悶+鍒嗙被璁ㄨ閮藉彲浠ヨ繃鐨勬牱瀛?/p>
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<cmath>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;
const int N = 505;
inline int read()
int v = 0,c = 1;char ch = getchar();
while(!isdigit(ch))
if(ch == '-') c = -1;
ch = getchar();
while(isdigit(ch))
v = v * 10 + ch - 48;
ch = getchar();
return v * c;
int a[N][N];
int b[N][N];
int tot;
int s[N];
int n,m;
inline bool pan()
for(int i = 1;i <= n;++i)
for(int j = 1;j <= n;++j)
if(b[i][j] != 1) return 0;
return 1;
inline bool check()
if(pan())
if(n & 1)
for(int i = 1;i <= n;++i) s[++tot] = 1;
return 1;
else return 0;
int main()
srand(time(0));
n = read(),m = read();
for(int i = 1;i <= n;++i) for(int j = 1;j <= m;++j) a[i][j] = read();
for(int t = 1;t <= 50000;++t)
int now = 0;
for(int i = 1;i < n;++i) s[i] = rand() % m + 1,now ^= a[i][s[i]];
for(int i = 1;i <= m;++i)
if((now ^ a[n][i]) != 0)
s[n] = i;
printf("TAK\n");
for(int j = 1;j <= n;++j) printf("%d ",s[j]);
return 0;
printf("NIE\n");
return 0;
C
~~杈i浮CF杩瀇_int128閮戒笉鏀寔~~
鎴戜滑灏嗘墍鏈夌殑鍖洪棿鍒嗘垚log鍧楀幓鑰冭檻
姣忎竴鍧楃殑鍐呴儴鍏跺疄閮芥槸绛夊樊鏁板垪
鎴戜滑鍙互鐢ㄧ瓑宸暟鍒楁眰鍜屽叕寮?/p>
瀵逛簬\(L,R\)灏辨眰涓€涓嬪墠缂€鍜?/p>
鍙﹀椤规暟鍙兘寰堝ぇ,涓€瀹氳%mod锛堟垜灏辨槸鍥犱负杩欎釜WA鐨勶級
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<cmath>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;
const LL mod = 1e9 + 7;
inline LL read()
LL v = 0,c = 1;char ch = getchar();
while(!isdigit(ch))
if(ch == '-') c = -1;
ch = getchar();
while(isdigit(ch))
v = v * 10 + ch - 48;
ch = getchar();
return v * c;
LL L,R;
LL sum[129];
LL shou[129];
inline LL quick(LL x,LL y)
LL res = 1;
while(y)
if(y & 1) res = res * x % mod;
y >>= 1;
x = x * x % mod;
return res;
LL inv2 = quick(2,mod - 2);
inline LL work(LL x)
if(x == 0) return 0;
LL cnt = 0;
LL gg = 0;
LL ans = 0;
while(gg + (1ll << cnt) <= x)
ans = (ans + sum[cnt]) % mod;
gg += (1ll << cnt);
cnt++;
if(gg != x)
LL rest = (x - gg) % mod;
LL rail = (shou[cnt] + (rest - 1) * 2 % mod) % mod;
ans = (ans + (shou[cnt] + rail) % mod * rest % mod * inv2 % mod) % mod;
return ans;
int main()
L = read(),R = read();
LL now = 0;
LL base = 0;
LL ji = 1;
LL ou = 2;
long long rr = R;
do
rr -= (1ll << base);
// printf("%lld\n",rr);
if(base & 1)
shou[base] = ou;
sum[base] = (ou + (ou + 2 * (quick(2,base) - 1) % mod) % mod) % mod * quick(2,base) % mod * inv2 % mod;
ou = (ou + 2 * (quick(2,base)) % mod) % mod;
else
shou[base] = ji;
sum[base] = (ji + (ji + 2 * (quick(2,base) - 1) % mod) % mod) % mod * quick(2,base) % mod * inv2 % mod;
ji = (ji + 2 * (quick(2,base)) % mod) % mod;
base++;
while(rr > 0);
// for(int i = 0;i <= base;++i) printf("%lld\n",(long long)(sum[i]));
long long ans = ((work(R) - work(L - 1) + mod) % mod + mod) % mod;
printf("%lld\n",(long long)ans);
return 0;
D
鍖栧紡瀛愬彲浠ュ彂鐜?鍙拰\(a_i-b_i\)鐨勫€兼湁鍏?/p>
鐒跺悗灏卞揩涔愭帓搴忕畻璐$尞
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<cmath>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;
const LL mod = 1e9 + 7;
inline LL read()
LL v = 0,c = 1;char ch = getchar();
while(!isdigit(ch))
if(ch == '-') c = -1;
ch = getchar();
while(isdigit(ch))
v = v * 10 + ch - 48;
ch = getchar();
return v * c;
LL L,R;
LL sum[129];
LL shou[129];
inline LL quick(LL x,LL y)
LL res = 1;
while(y)
if(y & 1) res = res * x % mod;
y >>= 1;
x = x * x % mod;
return res;
LL inv2 = quick(2,mod - 2);
inline LL work(LL x)
if(x == 0) return 0;
LL cnt = 0;
LL gg = 0;
LL ans = 0;
while(gg + (1ll << cnt) <= x)
ans = (ans + sum[cnt]) % mod;
gg += (1ll << cnt);
cnt++;
if(gg != x)
LL rest = (x - gg) % mod;
LL rail = (shou[cnt] + (rest - 1) * 2 % mod) % mod;
ans = (ans + (shou[cnt] + rail) % mod * rest % mod * inv2 % mod) % mod;
return ans;
int main()
L = read(),R = read();
LL now = 0;
LL base = 0;
LL ji = 1;
LL ou = 2;
long long rr = R;
do
rr -= (1ll << base);
// printf("%lld\n",rr);
if(base & 1)
shou[base] = ou;
sum[base] = (ou + (ou + 2 * (quick(2,base) - 1) % mod) % mod) % mod * quick(2,base) % mod * inv2 % mod;
ou = (ou + 2 * (quick(2,base)) % mod) % mod;
else
shou[base] = ji;
sum[base] = (ji + (ji + 2 * (quick(2,base) - 1) % mod) % mod) % mod * quick(2,base) % mod * inv2 % mod;
ji = (ji + 2 * (quick(2,base)) % mod) % mod;
base++;
while(rr > 0);
// for(int i = 0;i <= base;++i) printf("%lld\n",(long long)(sum[i]));
long long ans = ((work(R) - work(L - 1) + mod) % mod + mod) % mod;
printf("%lld\n",(long long)ans);
return 0;
E
棣栧厛涓€涓皬\(trick\)
杩為€氬潡鏁?= 鐐规暟 - 杈规暟
鎵€浠ョ瓟妗堝彉鎴愪簡鐐规暟涔嬪拰鍑忓幓杈规暟涔嬪拰
瀵逛簬涓€涓偣\(i\),浠栫殑璐$尞搴旇鏄?br />
\[
a_i*(n - a_i + 1)
\]
灏辨槸宸︾鐐瑰拰鍙崇鐐圭殑鍙栧€奸兘瑕佸悎娉?/p>
涓€鏉¤竟瀛樺湪浠呭綋浠栭摼鎺ョ殑涓や釜鐐归兘瀛樺湪
\[
min(a_i,a_i + 1) * (n - max(a_i,a_i + 1) + 1)
\]
以上是关于CF1151div2(Round 553)的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #553 (Div. 2) C题
Codeforces Round #553 (Div. 2) B题