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;
}
相关推荐
CodeWithMe6 分钟前
【读书笔记】《C++ Software Design》第一章《The Art of Software Design》
开发语言·c++
Tanecious.1 小时前
C++--红黑树
开发语言·c++
tanyongxi664 小时前
C++ Map 和 Set 详解:从原理到实战应用
开发语言·c++
飒飒真编程4 小时前
C++类模板继承部分知识及测试代码
开发语言·c++·算法
救赎小恶魔6 小时前
C++11的整理笔记
c++·笔记
岁忧6 小时前
(LeetCode 面试经典 150 题 ) 209. 长度最小的子数组(双指针)
java·c++·算法·leetcode·面试·go
小何好运暴富开心幸福6 小时前
分层架构的C++高并发内存池性能优化
c++·性能优化·架构
汉克老师7 小时前
GESP2025年6月认证C++三级( 第三部分编程题(1)奇偶校验)
c++·gesp三级·gesp3级
教练、我想打篮球7 小时前
68 指针的减法操作
c++·c·struct
Mr_Xuhhh7 小时前
QWidget的属性
java·数据库·c++·qt·系统架构