心情不好,被遣散回学校 ,心态不好 ,为什么会累,一直微笑就好了

#include<bits/stdc++.h>
using namespace std;
int main()
{freopen("in","r",stdin);\freopen("out","w",stdout);int n ,k=0,s=0,a[10];cin>>n;for(int i=0;i<n;i++){cin>>a[i];if(a[i]<a[k]) k=i;s+=a[i];}if(n<2||a[k]==s-a[k]){cout<<-1;}else{cout<<1<<" "<<k+1<<endl;}
}

View Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = (int)1e4+5;
ll arr[maxn],n,k;
int main()
{cin>>n>>k;for(int i=0;i<n;i++) cin>>arr[i];ll num1=0 ,num2=0;vector<long long> v;for(int i=0;i<n-1;i++){if(arr[i]&1)num1++;else num2++;if(num1    == num2) v.push_back(abs(arr[i]-arr[i+1]));}ll s= 0,ans=0;if(v.size()==0) cout<<0<<endl;else{sort(v.begin(),v.end());for(int i=0;i<v.size();i++){s+=v[i];if(s>k)break;ans++;}cout<<ans<<endl;}}

View Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{freopen("in","r",stdin);\freopen("out","w",stdout); string str;ll n,m,k;cin>>n>>m>>k>>str;vector<int> v;int ans=0;if(str[0]=='0')ans =1;for(int i=1;i<n;i++){if(str[i]=='0'&&str[i-1]!='0') ans++;}ll cnt = LLONG_MAX;for(int i=0;i<ans;i++){cnt = min(cnt,m*i+k*(ans-i));}cout<<(cnt==LLONG_MAX?0:cnt) <<endl;
}

View Code

#include<bits/stdc++.h>
using namespace std;
#define REP(i,l,r) for(int i=l;i<=r;i++)
int main()
{set<long long> s;long long n;cin>>n;if(n<=10){REP(i,0,n) REP(j,0,n)REP(k,0,n)REP(l,0,n){if(i+j+k+l==n) s.insert(50*l+10*k+5*j+i);}cout<<s.size()<<endl;}else cout<<49ll*n-247<<endl;
}

View Code

#include<iostream>using namespace std;typedef long long ll;const ll mod = 998244353;ll pow(ll a, ll b) {ll ans = 1;while (b) {if (b & 1) {ans = ans * a % mod;}b >>= 1;a = a * a % mod;}return ans;
}int main() {ll n ;cin>>n;ll ans =0,cur= 1;for(int i=1;i<=n;i++){cur = cur*(n+1-i)*pow(i,mod-2);ll sign = pow(-1,i+1);ll val = pow(3,i)*pow(3,n*(n-i));ans = ans+(cur*sign*val);}ans = ans*2;cur =1 ;#if 0{cur = cur * (N + 1 - i) % mod * pow(i, mod - 2) % mod;ll sign = pow(-1, i + 1);ll val = pow(3, i) * pow(3, N * (N - i)) % mod;ans = (ans + (cur * sign * val) % mod) % mod;}ans = ans * 2 % mod;cur = 1;for (int i = 0; i < N; ++i) {ll sign = pow(-1, i + 1);ll val = (pow(-pow(3, i) + 1, N) - (pow(-pow(3, i), N))) % mod * 3 % mod;ans = (ans + cur * sign * val % mod) % mod;cur = cur * (N - i) % mod * pow(i + 1, mod - 2) % mod;}ans = (ans + mod) % mod;cout << ans << endl;return 0;#endif
}

View Code

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353 ;
ll ans,n;
ll q_pow(ll x,ll y)
{ll ans =1;while(y){if(y&1) ans = ans*x%mod;x=x*x%mod;y>>=1;}return ans;
}
int main()
{cin>>n;ans  = q_pow(3,n*n) - q_pow(q_pow(3,n)-3,n);for(ll i =0 ,t=1;i<=n;i++){ll b = q_pow(3,n-i);ll res = t*(q_pow(b,n) - q_pow(b-(i?1:3)+mod,n))%mod;if(i) res = res*3%mod;ans+=i&1?-res:res;t =t*(n-i)%mod*q_pow(i+1,mod-2)%mod;}cout<<(ans%mod+mod)%mod;
}

View Code

#include<bits/stdc++.h>
using namespace std;
using namespace std;typedef long long ll;const int N = 4010, K = 80, P = 998244353;int k;
int comb[K][K];
int a1[K], a2[K];
pair<int, int> t1[N], t2[N];void solve(int n, pair<int, int>* t, int* a);int main() {int n, m;scanf("%d%d%d", &n, &m, &k);if (k % 2) {puts("0");return 0;}k /= 2;for (int i = 1; i < n; ++i)scanf("%d%d", &t1[i].first, &t1[i].second);for (int i = 1; i < m; ++i)scanf("%d%d", &t2[i].first, &t2[i].second);solve(n, t1, a1);solve(m, t2, a2);for (int i = 0; i <= k * 2; ++i) {comb[i][0] = 1;for (int j = 1; j <= i; ++j) {comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];if (comb[i][j] >= P)comb[i][j] -= P;}}int ans = 0;for (int i = 0; i <= k; ++i)ans = (ans + (ll)comb[k * 2][i * 2] * a1[i] % P * a2[k - i] % P) % P;printf("%d\n", ans);return 0;
}void solve(int n, pair<int, int>* t, int* a) {static int dp[K][N * 3], sum[K][N];memset(dp, 0, sizeof(dp));memset(sum, 0, sizeof(sum));for (int i = 0; i <= n * 3 - 2; ++i)dp[0][i] = 1;for (int i = 1; i <= k; ++i) {for (int e = 1; e < n; ++e) {int u = t[e].first, v = t[e].second;sum[i - 1][u] += dp[i - 1][n * 2 - 1 + e];if (sum[i - 1][u] >= P)sum[i - 1][u] -= P;sum[i - 1][v] += dp[i - 1][n + e];if (sum[i - 1][v] >= P)sum[i - 1][v] -= P;}for (int j = 0; j < i; ++j) {for (int e = 1; e < n; ++e) {int u = t[e].first, v = t[e].second;dp[i][u] = (dp[i][u] + dp[j][u] * (ll)dp[i - j - 1][n * 2 - 1 + e]) % P;dp[i][v] = (dp[i][v] + dp[j][v] * (ll)dp[i - j - 1][n + e]) % P;dp[i][n + e] = (dp[i][n + e] + dp[j][n + e] * (ll)(sum[i - j - 1][u] - dp[i - j - 1][n * 2 - 1 + e]) % P + P) % P;dp[i][n * 2 - 1 + e] = (dp[i][n * 2 - 1 + e] + dp[j][n * 2 - 1 + e] * (ll)(sum[i - j - 1][v] - dp[i - j - 1][n + e]) % P + P) % P;}}}for (int i = 0; i <= k; ++i) {for (int u = 1; u <= n; ++u) {a[i] += dp[i][u];if (a[i] >= P)a[i] -= P;}}
}

View Code

这个真的没有心情切掉,看看诡异的算法

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){static char buf[100000],*p1=buf,*p2=buf;return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){ll x = 0; char ch = gc(); bool positive = 1;for (; !isdigit(ch); ch = gc())    if (ch == '-')    positive = 0;for (; isdigit(ch); ch = gc())    x = x * 10 + ch - '0';return positive ? x : -x;
}
inline void write(ll a){if(a<0){a=-a; putchar('-');}if(a>=10)write(a/10);putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=120005,block=300,B=N/block+3,inf=1000000005;
int n,q,a[N],belong[N],mzs[N],p[N],l[N],r[N],q1[N],q2[N],t1,t2,val[N],cnt[B],lazy[B],L[B],R[B];
PI mn[N];
ll ans[N];
PI operator +(PI a,PI b){if(a.second==0)return b; else if(b.second==0)return a;return a.first==b.first?mp(a.first,a.second+b.second):(a.first>b.first?a:b);
}
void bao(int l,int r,int x){//cout<<l<<" "<<r<<" "<<x<<endl;int id=belong[l];for(int i=l;i<=r;i++)a[i]+=x;mn[id]=mp(inf,0); for(int i=L[id];i<=R[id];i++)mn[id]=mn[id]+mp(a[i],1);
}
void down(int x){if(!mzs[x])return;for(int i=L[x];i<=R[x];i++)if(a[i]==mn[x].first){val[i]+=mzs[x];}mzs[x]=0;
}
void ins(int l,int r,int x){if(l>r)return;if(belong[l]==belong[r]){down(belong[l]); bao(l,r,x); return;}down(belong[l]); bao(l,R[belong[l]],x);down(belong[r]); bao(L[belong[r]],r,x);for(int i=belong[l]+1;i<belong[r];i++)lazy[i]+=x;
}
void upd(){for(int i=1;i<=belong[n];i++)if(mn[i].first+lazy[i]==0){mzs[i]++; cnt[i]+=mn[i].second;}
}
ll ask(int l){ll ans=0; down(belong[l]);for(int i=l;i<=R[belong[l]];i++)ans+=val[i];for(int i=belong[l]+1;i<=belong[n];i++)ans+=cnt[i];return ans;
}
vector<int> v[N];
int main(){n=read();for(int i=1;i<=n;i++){p[i]=read();if((i-1)%block==0)L[belong[i]=belong[i-1]+1]=i; else belong[i]=belong[i-1];R[belong[i]]=i;a[i]=-1; mn[belong[i]]=mn[belong[i]]+mp(-1,1);}q=read();for(int i=1;i<=q;i++){l[i]=read(); r[i]=read();v[r[i]].push_back(i);}for(int i=1;i<=n;i++){while(p[q1[t1]]<p[i]&&t1){ins(q1[t1-1]+1,q1[t1],-p[i]+p[q1[t1]]); t1--; }q1[++t1]=i;while(p[q2[t2]]>p[i]&&t2){ins(q2[t2-1]+1,q2[t2],p[i]-p[q2[t2]]); t2--;}q2[++t2]=i;ins(1,i,1); upd();//for(int i=1;i<=n;i++)cout<<a[i]<<" "; puts("");//cout<<mzs[1]<<" "<<mn[1].first<<" szb"<<lazy[1]<<" "<<cnt[2]<<" "<<endl;for(unsigned j=0;j<v[i].size();j++)ans[v[i][j]]=ask(l[v[i][j]]);}for(int i=1;i<=q;i++)writeln(ans[i]);
} 

View Code

转载于:https://www.cnblogs.com/corx/p/9288715.html

Codeforces Round 493相关推荐

  1. Codeforces Round #493 (Div. 2) C. Convert to Ones 乱搞_构造_好题

    题意: 给你一个长度为 nnn 的 010101串 ,你有两种操作: 1.将一个子串翻转,花费 XXX 2.将一个子串中的0变成1,1变成0,花费 YYY 求你将这个01串变成全是1的串的最少花费. ...

  2. Cutting Codeforces Round #493 (Div. 2)

    Cutting There are a lot of things which could be cut - trees, paper, "the rope". In this p ...

  3. Codeforces Round #493 (Div. 2):D. Roman Digits

    题意(转换后):给你一个n,问在满足x+y+a+b=n的情况下,x+5y+10a+50b有多少种不同的结果 结论:当n≤11的时候直接暴力,n≥12满足F(i)=F(i-1)+49 思路:假设有这样道 ...

  4. Codeforces Round #493 (Div. 2):C. Convert to Ones

    题意:给你一个01串,你有两种操作:①翻转某个子串,代价为x:②将某个子串的0和1全部取反,代价为y,求将整个串全部修改成1的最小代价 思路:如果全为1,直接输出0,否则假设有p个连"0&q ...

  5. Educational Codeforces Round 90 (Rated for Div. 2)(A, B, C, D, E)

    Educational Codeforces Round 90 (Rated for Div. 2) Donut Shops 思路 分三种情况: a==c/ba == c / ba==c/b这个时候两 ...

  6. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  7. Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈)

    Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈) 标签: codeforces 2017-06-02 11:41 29人阅读 ...

  8. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

  9. Codeforces Round #270

    Codeforces Round #270 题目链接 A:我是筛了下素数.事实上偶数仅仅要输出4和x - 4,奇数输出9和x - 9就可以 B:贪心的策略,把时间排序后.取每k个的位置 C:贪心.每次 ...

最新文章

  1. 常用eclipse插件集合, 持续更新
  2. Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
  3. 最小割板子题——[USACO5.4]奶牛的电信
  4. jquery input值改变事件_前端技术--JQuery
  5. 使用jquery调试ajax接口-2
  6. 小程序 报错errMsg: “hideLoading:fail:toast can‘t be found“ ?
  7. python与数据处理_python数据处理:数据合并和Reshaping
  8. 不同电脑进入bios按键汇总
  9. 软件测试中的“银行企业银行对公渠道转账和财务查询和银企对账项目”
  10. 微型计算机中的rom跟ram关系,STC单片机内部扩展RAM的应用
  11. 最简单日柱推算法_日柱的简单计算方法
  12. 重启osd服务失败:Start request repeated too quickly
  13. 嵌入式Linux--根文件系统(二)BusyBox构建根文件系统
  14. html页眉页脚独立,word中怎样单独页面设置页眉
  15. 【PAT】A1114 Family Property (25 point(s))
  16. Vue中el-table追加行后固定列滚动错位问题
  17. 22. 将文件映射到内存
  18. 英汉词典 JaVa_Java案例_英汉字典_技术文章
  19. 解决卸载CleanMyMac后通知中心仍有通知的问题
  20. Spring @Pointcut使用

热门文章

  1. python消息队列中间件_python-RabbtiMQ消息队列
  2. mysql数据库访问问题吗_#MySQL数据库无法远程访问的问题
  3. 计算机二级目录设置,word2设置标题格式,生成目录,奇偶页设置等等,适用考计算机二级办公软件,也适用于毕业论文格式设置...
  4. oracle 11203 ora32701,11G RAC ORA-32701 参考学习
  5. C++多线程快速入门(三):生产者消费者模型与条件变量使用
  6. 关于placement new 和 placement delete的重载,以及basic_string重载new()实例
  7. javascript运算符_JavaScript中的按位运算符
  8. kotlin 判断数字_Kotlin程序检查给定数字是正数,负数还是零
  9. 第1章 数据库系统概述
  10. Java——获取和设置多线程的名称