当前位置:网站首页>Educational Codeforces Round 122 (Rated for Div. 2) ABC
Educational Codeforces Round 122 (Rated for Div. 2) ABC
2022-07-05 01:37:00 【Vijurria】
The main idea of the topic : Put an integer n, Change its lowest digit to make it 7 Multiple .
Note that the need cannot contain a preamble 0.
input
3 42 23 377output
42 28 777
Directly control its lowest position without crossing the boundary .
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
int t,n,m;
cin>>t;
while(t--)
{
int n;
cin>>n;
if(n%7==0) cout<<n<<endl;
else
{
if(n%10>=n%7) cout<<n-n%7<<endl;
else cout<<n+(7-n%7)<<endl;
}
}
return 0;
}
The main idea of the topic : Given one, only 0 and 1 Composed string s, Select a substring , If 0 The number of >1, Then delete 1 The number of , On the contrary, if 1 The number of >0, Then delete 0 The number of .
a key (wa spot ) coming :If the amounts are the same, do nothing.
input
4 01 1010101010111 00110001000 1output
0 5 3 0
If the amounts are the same, do nothing. If sum0==sum1, Don't do anything ?
WA Once + Read the title again and find : Select substring , You have to delete the maximum number , So if I have a string s:“010101”
If I choose the whole string , You can only get 0
However, if I choose a string from it “01010”, Successfully found the difference between size ,so↓
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
int t,n,m;
cin>>t;
while(t--)
{
string s;
cin>>s;
int one=0,zero=0;
for(int i=0;i<s.size();i++)
{
if(s[i]=='0') zero++;
else one++;
}
if(zero==one) cout<<zero-1<<endl;
else cout<<min(zero,one)<<endl;
}
return 0;
}
The main idea of the topic : Game character health hc, aggressivity dc; Monster health hm, aggressivity dm.
The roles before the war are k A coin , One coin can be purchased separately w Attack power , Or is it a The life value of the .
Ask the character if he can win the monster ?
input
4 25 4 9 20 1 1 10 25 4 12 20 1 1 10 100 1 45 2 0 4 10 9 2 69 2 4 2 7output
YES NO YES YES
Be careful : If the judgment condition is written ca/d>=c/cb Meeting wa. And write it ( The life value of the character + The attack power of monsters -1)/ The attack power of monsters >=( Monster health + The attack power of the character -1)/ The attack power of the character . Because we will encounter the problem of remainder , So you need to round up ceil
eg:(5+2-1)/2=3 5/2=2;
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--)
{
LL a,b,c,d,k,bb,aa;
cin>>a>>b>>c>>d>>k>>bb>>aa;
bool flag=false;
for(LL i=0;i<=k;i++)
{
LL ca=a+i*aa;
LL cb=b+(k-i)*bb;
//cout<<ca<<" "<<cb<<" "<<c<<" "<<d;
if((ca+d-1)/d>=(cb+c-1)/cb)
{
flag=true;
cout<<"YES"<<endl;
break;
}
}
if(flag==false) cout<<"NO"<<endl;
}
return 0;
}
边栏推荐
- Basic operations of database and table ----- delete index
- node工程中package.json文件作用是什么?里面的^尖括号和~波浪号是什么意思?
- 流批一體在京東的探索與實踐
- Database postragesq role membership
- 增量备份 ?db full
- Database performance optimization tool
- MATLB | multi micro grid and distributed energy trading
- 微信小程序:全新独立后台月老办事处一元交友盲盒
- What is the current situation and Prospect of the software testing industry in 2022?
- Global and Chinese market of veterinary thermometers 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
LeetCode周赛 + AcWing周赛(T4/T3)分析对比
Wechat applet: wechat applet source code download new community system optimized version support agent member system function super high income
Roads and routes -- dfs+topsort+dijkstra+ mapping
Four pits in reentrantlock!
To sort out messy header files, I use include what you use
MySQL regexp: Regular Expression Query
Do you know the eight signs of a team becoming agile?
流批一体在京东的探索与实践
Application and Optimization Practice of redis in vivo push platform
Remote control service
随机推荐
Armv8-a programming guide MMU (3)
Database postragesq BSD authentication
如果消费互联网比喻成「湖泊」的话,产业互联网则是广阔的「海洋」
If the consumer Internet is compared to a "Lake", the industrial Internet is a vast "ocean"
PowerShell:在代理服务器后面使用 PowerShell
Five ways to query MySQL field comments!
What sparks can applet container technology collide with IOT
微信小程序:微群人脉微信小程序源码下载全新社群系统优化版支持代理会员系统功能超高收益
微信小程序;胡言乱语生成器
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
【大型电商项目开发】性能压测-性能监控-堆内存与垃圾回收-39
Global and Chinese markets for industrial X-ray testing equipment 2022-2028: Research Report on technology, participants, trends, market size and share
Robley's global and Chinese markets 2022-2028: technology, participants, trends, market size and share Research Report
Global and Chinese markets of radiation linear accelerators 2022-2028: Research Report on technology, participants, trends, market size and share
Yyds dry goods inventory [Gan Di's one week summary: the most complete and detailed in the whole network]; detailed explanation of MySQL index data structure and index optimization; remember collectio
Jcenter () cannot find Alibaba cloud proxy address
Hedhat firewall
One plus six brushes into Kali nethunter
Interesting practice of robot programming 15- autoavoidobstacles
微信小程序:独立后台带分销功能月老办事处交友盲盒