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++基础语法下(引用 内联函数 auto关键字 范围for 指针空值)
开发语言·c++
windxgz1 小时前
FFmpeg——视频拼接总结
c++·ffmpeg·音视频
GSDjisidi2 小时前
日本IT-SIER/SES的区别详情、契约形态等
java·大数据·c语言·c++·php
YoungMLet2 小时前
【QT】多元素控件
c语言·开发语言·c++·qt·ui
paidaxing_s3 小时前
【FFMPEG基础(一)】解码源码
linux·c++·ffmpeg
曼巴UE53 小时前
UE C++ 多镜头设置缩放 平移
开发语言·c++
悄悄敲敲敲3 小时前
栈的实现详解
c语言·开发语言·数据结构·c++·算法·链表·线性回归
danaaaa3 小时前
算法力扣刷题总结篇 ——【四】
数据结构·c++·算法·leetcode·职场和发展
安於宿命3 小时前
0/1背包问题总结
c语言·c++·算法·leetcode·动态规划
tutu_3214 小时前
ubuntu rc.local开机自启动
c++