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;
}
相关推荐
hd51cc1 天前
MFC 文档/视图 二
c++·mfc
wzfj123451 天前
认识lambda
c++
老王熬夜敲代码1 天前
C++万能类:any
开发语言·c++·笔记
智者知已应修善业1 天前
【数组删除重复数据灵活算法可修改保留重复数量】2024-3-4
c语言·c++·经验分享·笔记·算法
Cappi卡比1 天前
【无标题】
c++
汉克老师1 天前
GESP2025年12月认证C++五级真题与解析(编程题2 (相等序列))
c++·算法·贪心算法·中位数·质数分解
UP_Continue1 天前
C++--可变参数模板和lambda
开发语言·c++
jiunian_cn1 天前
【C++11】C++11重要新特性详解
开发语言·c++
tbRNA1 天前
C/C++ 内存管理
c语言·c++
WBluuue1 天前
AtCoder Beginner Contest 438(ABCDEF)
c++·算法