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;
}
相关推荐
buyue__11 分钟前
C++实现数据结构——线性表
数据结构·c++
fantasy5_51 小时前
手撕vector:从零实现一个C++动态数组
java·开发语言·c++
兜兜风d'1 小时前
RabbitMQ死信队列详解
c++·rabbitmq·java-rabbitmq
C_Liu_1 小时前
12.C++:模版进阶
开发语言·c++
娇娇yyyyyy2 小时前
C++11新特性基础知识点汇总
开发语言·c++·算法
Benny_Tang3 小时前
CSP-J/S 2025 游记
c++
simple_whu3 小时前
编译tiff:arm64-linux-static报错 Could NOT find CMath (missing: CMath_pow)
linux·运维·c++
彩妙不是菜喵3 小时前
初学C++:函数大转变:缺省参数与函数重载
开发语言·c++
小龙报3 小时前
《算法通关指南算法千题篇(5)--- 1.最长递增,2.交换瓶子,3.翻硬币》
c语言·开发语言·数据结构·c++·算法·学习方法·visual studio
yy_xzz3 小时前
Debian 系统中 Qt Creator 用 sudo 启动后权限问题
c++·qt