期望得分:100+100+30=230 实际得分: 正解: 枚举最高的位,这一位m是1但实际用了0 然后剩余的低位肯定是 正数就用1,负数用0 考场思路:数位DP #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; typedef long long LL; #define N 100001 int a[N]; char…
T1 贪心 10 元先找5元 20元 先找10+5,再找3张5 #include<cstdio> using namespace std; int m5,m10,m20; int main() { freopen("book.in","r",stdin); freopen("book.out","w",stdout); int n; scanf("%d",&n); int x; ;i&l…
LI /* 没有考虑次大值有大于一个的情况 */ #include<iostream> #include<cstdio> #include<cstring> #define N 1000007 using namespace std; int n,m,ans,cnt,mx; int a[N]; inline int read() { ,f=;char c=getchar(); ;c=getchar();} +c-';c=getchar();} return x*f;…
三向城 /* 原图一定是一棵完全二叉树. 根节点是x,左节点是x*2,右节点是x*2+1 转化为二进制往左右走就很明显了. */ #include<iostream> #include<cstdio> #include<cstring> #define ll long long using namespace std; int T,x,y,k,ans,pos; inline int read() { ,f=;char c=getchar(); ;c=getchar();…
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define N 1000010 using namespace std; int n,a[N],cnt1,cnt2; int read() { ,f=;char c=getchar(); ;c=getchar();} +c-';c=getchar();} ; } int main() { scanf(&quo…
/* 可以并查集维护 可以发现,某个联通快出现大于等于2个环,一定无法分配. 有解要么一个环,要么没有环. 一个环时答案等于点数乘2(顺时针或逆时针). 没有环是树,对于一个n个点的树,方案一定有n种(不连某个点). */ #include<iostream> #include<cstdio> #include<cstring> #define N 100007 #define mod 1000000007 #define ll long long using name…
#include<iostream> #include<cstdio> #include<cstring> #include<stack> #define N 100007 using namespace std; char ch[N]; int ans,pos; stack<char>s; int main() { freopen("shower.in","r",stdin); freopen("…