本来准备鸽了的 但后来还是打了
打开电脑 登进比赛 zw他们都过了一题了
然后 b题x,y写反了wa4发
c题题目意思一开始没搞懂 又浪费了好久时间
d题wa2代码第二天早上重新看了下 加了个等号就a了
整个打下来有点想死 心态崩了
估计又要掉分

A. Yet Another Two Integers Problem

题目思路

一个很简单的贪心问题
直接做差除10再向上取整就好了

ac代码

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include  <map>
#include <set>
#include <utility>
#define pi 3.1415926535898
#define ll long long
#define lson rt<<1
#define rson rt<<1|1
#define eps 1e-6
#define ms(a,b) memset(a,b,sizeof(a))
#define legal(a,b) a&b
#define print1 printf("111\n")
using namespace std;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000007;
//998244353int a[maxn];int main()
{int _;scanf("%d",&_);while(_--){int n,m;scanf("%d%d",&n,&m);int tem=abs(n-m);if(tem%10==0)printf("%d\n",tem/10);elseprintf("%d\n",tem/10+1);}
}

B. Minimum Product

题目思路

这题也很简单
就对情况分个类
然后对各个类按照题目要求处理就好了

ac代码

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include  <map>
#include <set>
#include <utility>
#define pi 3.1415926535898
#define ll long long
#define lson rt<<1
#define rson rt<<1|1
#define eps 1e-6
#define ms(a,b) memset(a,b,sizeof(a))
#define legal(a,b) a&b
#define print1 printf("111\n")
using namespace std;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000007;
//998244353ll a,b,x,y,n;ll cal(ll a,ll b,ll x,ll y,ll n)
{ll ans=1e18;ll temn=n;if(b-y>=n){ans=min(ans,1ll*a*(b-n));}else{n-=b-y;int m=min(a-x,n);a-=m;ans=min(ans,1ll*a*(y));}return ans;
}int main()
{int _;scanf("%d",&_);while(_--){scanf("%lld%lld%lld%lld%lld",&a,&b,&x,&y,&n);ll ans=1e18;ans=min(ans,cal(a,b,x,y,n));ans=min(ans,cal(b,a,y,x,n));printf("%lld\n",ans);}
}

C. Yet Another Array Restoration

题目思路

题目要求输出包含下x和y的n个排序后等差的数组
并且要求这个数组的最大值最小
观察到题目的n很小
直接对y和x做差 找x到y的公差就好了
这个公差不一定是最小的
因为如果公差太小 x到y之间的值就超过了n个 最终y不被输出
如果x到y之间满足条件的值少于n
就先从小于x的值补 在不够就从大于y的值补

ac代码

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include  <map>
#include <set>
#include <utility>
#define pi 3.1415926535898
#define ll long long
#define lson rt<<1
#define rson rt<<1|1
#define eps 1e-6
#define ms(a,b) memset(a,b,sizeof(a))
#define legal(a,b) a&b
#define print1 printf("111\n")
using namespace std;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000007;
//998244353int n,x,y;int main()
{int _;scanf("%d",&_);while(_--){scanf("%d%d%d",&n,&x,&y);if(n==2){printf("%d %d\n",x,y);}else{int tem=y-x;int num=0;for(int i=n-1;i>=1;i--){if(tem%i==0){num=i;break;}}tem=tem/num;if(num!=n)num++;//printf("%d\n",num);for(int i=0;i<num;i++){printf("%d ",x+i*(tem));}//printf("\n");while(num<n){if(x-tem>=1){x-=tem;printf("%d ",x);num++;}else{y+=tem;printf("%d ",y);num++;}}printf("\n");}}
}

D. Decrease the Sum of Digits

题目思路

对于这题 我们可以先找到要满足s n需要改变到的值
再将它和n相减就好了
我们可以先统计n的每个数位上值的和
从小的数位往大的数位 判断需要改变到的最小数位
然后从大往小乘回来就好了
具体操作看代码

ac代码

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include  <map>
#include <set>
#include <utility>
#define pi 3.1415926535898
#define ll long long
#define lson rt<<1
#define rson rt<<1|1
#define eps 1e-6
#define ms(a,b) memset(a,b,sizeof(a))
#define legal(a,b) a&b
#define print1 printf("111\n")
using namespace std;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000007;
//998244353int mp[30],ans[30];
int main()
{int _;scanf("%d",&_);int cnt=0;while(_--){cnt++;//if(cnt==50)printf("nn\n");ll n,s;scanf("%lld%lld",&n,&s);ans[0]=0;for(int i=1;i<=30;i++)mp[i]=ans[i]=0;ll tem=n;ll sum=0;ll num=0;while(tem>0){num++;sum+=tem%10;mp[num]=tem%10;ans[num]+=ans[num-1]+mp[num];tem/=10;}//printf("%d\n",num);if(sum<=s){printf("0\n");}else{int flag=0;//printf("%d\n",ans[1]);for(int i=2;i<=num;i++){if(sum-ans[i-1]+1<=s){flag=i;break;}}if(flag!=0){ll ans1=0;for(int i=num;i>=flag;i--){if(i!=flag){ans1=ans1*10+mp[i];}else{ans1=ans1*10+mp[i]+1;}}for(int i=flag-1;i>=1;i--){ans1*=10;}printf("%lld\n",ans1-n);}else{ll ans1=1;for(int i=1;i<=num;i++){ans1*=10;}printf("%lld\n",ans1-n);}}}
}

Codeforces Round #667 (Div. 3) abcd相关推荐

  1. Codeforces Round #143 (Div. 2) (ABCD 思维场)

    题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...

  2. Codeforces Round #250 (Div. 2) (ABCD题解)

    比赛链接:http://codeforces.com/contest/437 A. The Child and Homework time limit per test:1 second memory ...

  3. Codeforces Round #667 (Div. 3)

    A - Yet Another Two Integers Problem 数学题,每次先加减10,最后一步缺多少加减多少 #define IO ios::sync_with_stdio(false); ...

  4. Codeforces Round #717 (Div. 2)(ABCD)

    A. Tit for Tat 从前往后枚举,把前面的数减到0,然后给最后一个数加上去.操作次数没了就停止 #include<bits/stdc++.h> using namespace s ...

  5. Codeforces Round #777 (Div. 2) ABCD题解

    A-Madoka and Math Dad 题目大意: 一个十进制数字(不含0),各个位上的和为n(n<=1000),且相邻位没有相同的数字,问这个数字最大可以是多少. 思路: 显然要使这个数字 ...

  6. Codeforces Round #695 (Div. 2)ABCD题解详析

    A. Wizard of Orz 首先保证第一块板子是999,那么第二块板子不可能是999,那么令第二块板子为888 只要在第二块板到达888的时候按下暂停,那么第一块是999,第三块板子也是999 ...

  7. Codeforces Round #782 (Div. 2) ABCD

    打昆明打傻了,不会写题了QWQ A - Red Versus Blue 要求连续的 R R R的数量最少,也就是用 B B B尽可能的将 R R R隔开,显然 b b b个 B B B最多分成 b + ...

  8. Codeforces Round #666 (Div. 1) ABCD(E)题解

    目录 比赛记录: A B C D Solution 1 Solution 2 Solution 3 Solution 4 E(目前不太会,正在尝试) 比赛记录: 00:00:00 Participan ...

  9. Codeforces Round #770 (Div. 2) ABCD题解

    A. Reverse and Concatenate 思路: 答 案 要 么 1 要 么 2 答案要么1要么2 答案要么1要么2 等 于 1 的 必 要 条 件 是 反 转 之 后 是 它 本 身 等 ...

最新文章

  1. 如何使用Create-React-App和自定义服务人员构建PWA
  2. mysql查看存储过程工作记录20130711
  3. oracle中create table with as和insert into with as语句
  4. python编程课程上课有用吗-朋友圈里的编程课,是 Python 还是成功学?
  5. 指针系统学习7-返回指针值的函数
  6. Java 设计模式之迭代器模式
  7. 小括号教学设计导入_【教资面试】语文政治历史地理教学设计答题技巧!
  8. 安徽计算机对口大学有哪些专业,计算机专业对口升学安徽院校
  9. latex图片_Latex使用图片、文献、模板——自定义与路径指定
  10. 《FilthyRichClients》读书笔记(一)-SwingのEDT
  11. 汇编笔记-DOSBox安装和使用
  12. 天主教、新教、东正教
  13. mybatis多字段排序_解决mybatis中order by排序无效问题
  14. puppet的相关介绍
  15. 在ubuntu下安装和配置vsftpd
  16. C++类头文件交叉引用出现error C2143: 语法错误: 缺少“
  17. 数据分析和数据开发的区别
  18. python 3d绘图kmeans_使用Python matplotlib绘制3D多边形!
  19. 生动理解java接口
  20. mybatis-plus乐观锁重试机制配置重置次数

热门文章

  1. jitsi-meet安卓端进入房间就断开连接
  2. ppa:ondrej/php,现在为什么 Ubuntu ppa:ondrej/PHP 添加不了??
  3. Postgresql 逆向工程的SQL文
  4. python樱花手绘_宫崎骏动画里的新垣结衣见过没?这个开源动漫生成器让你的照片秒变手绘日漫...
  5. java web编程技术上机实验_JavaWeb編程技术实验指导书.doc
  6. 四名8090后小伙做网游私服,两年赚540万
  7. 我对软件测试行业的看法
  8. RSA与大数运算(C语言)
  9. postgresql15.2下载安装详细教程(win10)
  10. 基于ActionScript3.0的DoodleJump 游戏实现