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语言指针一】从入门到通透:核心知识点全梳理(内存、变量、运算、const修饰)
c语言·开发语言·c++
蓑衣夜行4 分钟前
QtWebEngine 自动重启方案
开发语言·c++·qt·web·qwebengine
Source.Liu6 分钟前
【LibreCAD】点实体源码解析
c++·qt·cad
煤球王子31 分钟前
学而时习之:C++中的标准模板库7
c++
一匹电信狗32 分钟前
【Linux我做主】进程实践:手动实现Shell
linux·运维·服务器·c++·ubuntu·小程序·开源
stanleyrain35 分钟前
C++中关于const的说明
开发语言·c++
一个不知名程序员www42 分钟前
算法学习入门---stack(C++)
c++·算法
oioihoii1 小时前
MFC核心架构深度解析
c++·架构·mfc
清风拂山岗 明月照大江1 小时前
TCP/IP网络编程_hello,world!
开发语言·c++
兵哥工控1 小时前
MFC 对话框线程简单完整实例
c++·mfc·线程·afxbeginthread