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;
}
相关推荐
仟濹1 天前
【C/C++】经典高精度算法 5道题 加减乘除「复习」
c语言·c++·算法
kk”1 天前
C++ map
开发语言·c++
共享家95271 天前
特殊类的设计
开发语言·c++
信奥卷王1 天前
2025年9月GESPC++三级真题解析(含视频)
开发语言·c++·算法
qq_433554541 天前
C++ 稀疏表
开发语言·c++·算法
Bona Sun1 天前
单片机手搓掌上游戏机(十二)—esp8266运行gameboy模拟器之编译上传
c语言·c++·单片机·游戏机
帅中的小灰灰1 天前
C++编程观察者设计模式
数据库·c++·设计模式
MSTcheng.1 天前
【C++STL】priority_queue 模拟实现与仿函数实战
开发语言·c++
还有几根头发呀1 天前
从 C++ 的角度,系统地解释 进程(Process)、线程(Thread)、协程(Coroutine) 的概念、原理、优缺点,以及常见应用场景。
c++
oioihoii1 天前
Python与C++:从哲学到细节的全面对比
c++