A:模拟水题不说

#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bitset> using namespace std;
typedef long long LL;
const int N= 1e3+;
char s[N][];
int main(){
int n;
scanf("%d",&n);
for(int i=;i<=n;++i)scanf("%s",s[i]+);
bool flag=false;
for(int i=;i<=n;++i){
if(s[i][]==s[i][]&&s[i][]=='O'){
flag=true;
s[i][]=s[i][]='+';
break;
}
if(s[i][]==s[i][]&&s[i][]=='O'){
flag=true;
s[i][]=s[i][]='+';
break;
}
}
if(flag)printf("YES\n");
else printf("NO\n");
if(flag)
for(int i=;i<=n;++i)printf("%s\n",s[i]+);
return ;
}

B:n*n的方阵,只有一个位置是未填数的,然后问填数以后,行和列和主副对角线和相等
     O(n^2)模拟即可(这题FST了,由于输出格式不太对,对了这个也许能上更多分吧)

#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bitset> using namespace std;
typedef long long LL;
const int N= 5e2+;
LL a[N][N];
int main(){
int n,x,y;
scanf("%d",&n);
for(int i=;i<=n;++i){
for(int j=;j<=n;++j){
scanf("%I64d",&a[i][j]);
if(a[i][j]==){
x=i;
y=j;
}
}
}
if(n==){
printf("1\n");
return ;
}
LL sum=;
if(x==)
for(int i=;i<=n;++i)sum+=a[][i];
else
for(int i=;i<=n;++i)sum+=a[][i];
LL ret=-;
for(int i=;i<=n;++i){
LL tmp=;
for(int j=;j<=n;++j)
tmp+=a[i][j];
if(i==x){
if(tmp<sum){
if(ret!=-&&ret!=sum-tmp){
printf("-1\n");
return ;
}
else ret=sum-tmp;
}
else {
printf("-1\n");
return ;
}
}
else{
if(sum!=tmp){
printf("-1\n");
return ;
}
}
}
for(int j=;j<=n;++j){
LL tmp=;
for(int i=;i<=n;++i)
tmp+=a[i][j];
if(j==y){
if(tmp<sum){
if(ret!=-&&ret!=sum-tmp){
printf("-1\n");
return ;
}
else ret=sum-tmp;
}
else {
printf("-1\n");
return ;
}
}
else{
if(sum!=tmp){
printf("-1\n");
return ;
}
}
}
LL tmp=;
for(int i=;i<=n;++i)tmp+=a[i][i];
if(x==y){
if(tmp<sum){
if(ret!=-&&ret!=sum-tmp){
printf("-1\n");
return ;
}
else ret=sum-tmp;
}
else {
printf("-1\n");
return ;
}
}
else{
if(sum!=tmp){
printf("-1\n");
return ;
}
}
tmp=;
for(int i=;i<=n;++i)tmp+=a[i][n+-i];
if(x+y==n+){
if(tmp<sum){
if(ret!=-&&ret!=sum-tmp){
printf("-1\n");
return ;
}
else ret=sum-tmp;
}
else {
printf("-1\n");
return ;
}
}
else{
if(sum!=tmp){
printf("-1\n");
return ;
}
}
printf("%I64d\n",ret);
return ;
}

C:赛场上写了个裸的O(n^4)的dp,dp[i][j][k]代表当前是第i个数,这个数是j,分成k块的最小值
    由于是时限是2s,而且是CF评测机,不虚

#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bitset> using namespace std;
typedef long long LL;
const int N= 1e2+;
LL dp[N][N][N];
LL p[N][N];
int a[N];
int main(){
int n,m,k;
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<=n;++i)scanf("%d",&a[i]);
for(int i=;i<=n;++i){
for(int j=;j<=m;++j)
scanf("%I64d",&p[i][j]);
}
memset(dp,-,sizeof(dp));
if(a[]!=)dp[][a[]][]=;
else{
for(int i=;i<=m;++i)
dp[][i][]=p[][i];
}
for(int i=;i<=n;++i){
int lim=min(k,i);
if(a[i]!=){
for(int j=;j<=lim;++j){
for(int c=;c<=m;++c){
if(dp[i-][c][j-]!=-&&a[i]!=c){
if(dp[i][a[i]][j]==-)dp[i][a[i]][j]=dp[i-][c][j-];
else dp[i][a[i]][j]=min(dp[i][a[i]][j],dp[i-][c][j-]);
}
if(dp[i-][c][j]!=-&&a[i]==c)
if(dp[i][a[i]][j]==-)dp[i][a[i]][j]=dp[i-][c][j];
else dp[i][a[i]][j]=min(dp[i][a[i]][j],dp[i-][c][j]);
}
}
continue;
}
for(int x=;x<=m;++x){
for(int j=;j<=lim;++j){
for(int c=;c<=m;++c){
if(dp[i-][c][j-]!=-&&x!=c){
if(dp[i][x][j]==-)dp[i][x][j]=dp[i-][c][j-]+p[i][x];
else dp[i][x][j]=min(dp[i][x][j],dp[i-][c][j-]+p[i][x]);
}
if(dp[i-][c][j]!=-&&x==c)
if(dp[i][x][j]==-)dp[i][x][j]=dp[i-][c][j]+p[i][x];
else dp[i][x][j]=min(dp[i][x][j],dp[i-][c][j]+p[i][x]);
}
}
}
}
LL ret=-;
for(int i=;i<=m;++i)
if(dp[n][i][k]!=-){
if(ret==-)ret=dp[n][i][k];
else ret=min(ret,dp[n][i][k]);
}
printf("%I64d\n",ret);
return ;
}

D:这种题很常见,有向环套树,看每个环的反转方案,是2^k-2(k是边数,必须翻一个,不能全翻)
     剩下的树上的边翻不翻都可以是2^tot,tot代表树边,然后都乘起来即可

#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bitset>
using namespace std;
typedef long long LL;
const int N = 2e5+;
const LL mod = 1e9+;
int to[N],n;
int vis[N];
LL qpow(LL x,LL y){
LL ret=;
while(y){
if(y&)ret=ret*x%mod;
y>>=;
x=x*x%mod;
}
return ret;
}
int main(){
scanf("%d",&n);
for(int i=;i<=n;++i)scanf("%d",&to[i]);
LL z=n,ret=;
for(int i=;i<=n;++i){
if(vis[i])continue;
int x=i;
while(!vis[x]){
vis[x]=i;
x=to[x];
}
if(vis[x]!=i)continue;
int t=x,cnt=;
do{
++cnt;
t=to[t];
}while(t!=x);
z-=cnt;
ret=1ll*ret*((qpow(,cnt)-+mod)%mod)%mod;
}
ret=ret*qpow(,z)%mod;
printf("%I64d\n",ret);
return ;
}

E:考虑正难则反,概率等于1-A(k,2^n)/2^(nk),然后发现最大公约数只能是2^i,约分即可

#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bitset>
using namespace std;
typedef long long LL;
const int N = 2e5+;
const LL mod = 1e6+;
LL qpow(LL x,LL y){
LL ret=;
while(y){
if(y&)ret=ret*x%mod;
x=x*x%mod;y>>=;
}
return ret;
}
int main(){
LL n,k;
scanf("%I64d%I64d",&n,&k);
if(n<=&&k>1ll<<n){
printf("1 1\n");
return ;
}
LL num=;
for(LL i=k-;i;i>>=){
num+=i/;
}
LL b=,a=qpow(,n);
for(LL i=;i<=k-;++i){
LL tmp=(a-i+mod)%mod;
b=b*tmp%mod;
if(tmp==)break;
}
LL inv=qpow(qpow(,num),mod-);
a=qpow(a,k-);
a=a*inv%mod;
b=b*inv%mod;
b=(a-b+mod)%mod;
printf("%I64d %I64d\n",b,a);
return ;
}

Codeforces Round #369 (Div. 2) 套题的更多相关文章

  1. Codeforces Round #579 (Div. 3) 套题 题解

    A. Circle of Students      题目:https://codeforces.com/contest/1203/problem/A 题意:一堆人坐成一个环,问能否按逆时针或者顺时针 ...

  2. Codeforces Round #361 (Div. 2) 套题

    A - Mike and Cellphone 问有没有多解,每个点按照给出的序列用向量法跑一遍 #include<cstdio> #include<cstring> #incl ...

  3. Codeforces Round #367 (Div. 2) 套题

    吐槽:只能说是上分好场,可惜没打,唉 A:Beru-taxi (水题,取最小值) #include <cstdio> #include <cstring> #include & ...

  4. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  5. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

  6. Codeforces Round #713 (Div. 3)AB题

    Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...

  7. Codeforces Round #552 (Div. 3) A题

    题目网址:http://codeforces.com/contest/1154/problem/ 题目意思:就是给你四个数,这四个数是a+b,a+c,b+c,a+b+c,次序未知要反求出a,b,c,d ...

  8. Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring

    D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  9. Codeforces Round #369 (Div. 2)---C - Coloring Trees (很妙的DP题)

    题目链接 http://codeforces.com/contest/711/problem/C Description ZS the Coder and Chris the Baboon has a ...

随机推荐

  1. mysql批量插值

    将查询结果集插入到表中(适用批量插值) 将结果集插入 不需要添加VALUES INSERT INTO `erp`.`role_menu` (`ROLEUUID`, `MENUUUID`) (SELEC ...

  2. LVS-NAT负载均衡PHP应用(Wordpress、Discuz)

    1 实验拓扑 2 需求 RS-01和RS-02对外提供WEB服务. RS-01搭建LAMP,PHP通过http模块方式提供. RS-02搭建LAMP,PHP通过fpm方式提供. RS-01和RS-02 ...

  3. 使用java发送电子邮件

    经常在账号绑定邮箱或找回密码时,邮箱会收到一条验证邮件,好奇用代码该怎么发送邮件,看到了许多相关的博客,实现步骤都写的很详细,今天照着其他博客的步骤也确实实现了代码发送邮件,在这里重新记录下步骤,加深 ...

  4. Webdriver测试脚本2(控制浏览器)

    Webdriver提供了操作浏览器的一些方法,例如控制浏览器的大小.操作浏览器前进和后退等. 控制浏览器窗口大小 有时候我们希望能以某种浏览器尺寸打开,让访问的页面在这种尺寸下运行.例如可以将浏览器设 ...

  5. 2018/4/7 Mybatis源码结构概览

    在观看Mybatis源码的过程中,有一点疑惑,就是Mybatis的缓存设计明显有问题,首先,Mybatis缓存分为两级,先说一级,生命周期为一个sqlsession,只有在查询相同方法时才会命中缓存, ...

  6. 【BZOJ4868】期末考试(整数三分)

    题意: 有n位同学,每位同学都参加了全部的m门课程的期末考试,都在焦急的等待成绩的公布.第i位同学希望在第ti天 或之前得知所.有.课程的成绩.如果在第ti天,有至少一门课程的成绩没有公布,他就会等待 ...

  7. ELK pipeline

    https://www.felayman.com/articles/2017/11/24/1511527532643.html?utm_medium=hao.caibaojian.com&ut ...

  8. UVA 129_ Krypton Factor

    题意: 一个字符串含有两个相邻的重复的子串,则称这个串为容易的串,其他为困难的串,对于给定n,l,求出由前l个字符组成的字典序第n小的困难的串. 分析: 按字典序在字符串末尾增加新的字符,并从当前字符 ...

  9. JavaWeb图片显示与存储

    在数据库中存储文件的名称,在存储信息资料里面存下照片,利用文件名称. 代码如下: 其中iamgeFile为 图片存储的路径userImages/ Resultuser.setImageName(Pro ...

  10. 显示锁ReentrantLock和Condition的使用

    一.ReentrantLock (1).java.util.concurrent.locks包中的ReentrantLock就是重入锁,它实现了Lock接口,Lock加锁和解锁都是显示的.Reentr ...