cf练习5.29

A

ac代码

cpp 复制代码
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

using namespace std;

int main()
{
	IOS
	int t;
	cin>>t;
	while(t--)
	{
		int ans=0;
		int a,b;
		cin>>a>>b;
		if(b==0)
		{
			if(a%15==0) ans=a/15;
			else ans=a/15+1;
		}

		else if(b!=0 && b%2==0)
		{
			if(a<=b/2*7) ans=b/2;
			else{
				if((a-(b/2*7))%15==0) ans=b/2+((a-b/2*7)/15);
				else ans=b/2+((a-b/2*7)/15)+1;
			}
			//cout<<ans<<endl;
		}
		
		else if(b%2==1)
		{
			if(a<=(b/2*7+11)) ans=b/2+1;
			else {
				if((a-b/2*7-11)%15==0) ans=b/2+1+(a-b/2*7-11)/15;
				else ans=b/2+1+(a-b/2*7-11)/15+1;
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}
相关推荐
Fuyo_11191 天前
带你了解C++的类与对象(中)
c++
小苗卷不动1 天前
UDP服务端收发流程
linux·c++·udp
Xiu Yan1 天前
Java 转 C++ 系列:函数模板
java·开发语言·c++
小苗卷不动1 天前
OJ练习之加减(中等偏难)
c++
我能坚持多久1 天前
String类常用接口的实现
c语言·开发语言·c++
智者知已应修善业1 天前
【数字稳压控制DAC/TLC5615驱动】2023-5-27
c++·经验分享·笔记·算法·51单片机
t***5441 天前
Orwell Dev-C++和Embarcadero Dev-C++哪个更稳定
开发语言·c++
代码中介商1 天前
C++运行时多态深度解析:从原理到实践
开发语言·c++·多态·虚函数
代码中介商1 天前
C++ 继承与派生深度解析:存储布局、构造析构与高级特性
开发语言·c++·继承·派生
谭欣辰1 天前
C++ 控制台跑酷小游戏2.0
开发语言·c++·游戏程序