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 天前
android ndk c++ 绘制图片方式
android·c++·python
散峰而望1 天前
【基础算法】算法的“预谋”:前缀和如何改变游戏规则
开发语言·数据结构·c++·算法·github·动态规划·推荐算法
仰泳的熊猫1 天前
题目1432:蓝桥杯2013年第四届真题-剪格子
数据结构·c++·算法·蓝桥杯·深度优先·图论
闻缺陷则喜何志丹1 天前
【数论 快速指数幂 龟速乘】P8652 [蓝桥杯 2017 国 C] 小数第 n 位|普及+
c++·蓝桥杯·数论·快速指数幂·龟速乘
༾冬瓜大侠༿1 天前
C++string
c语言·开发语言·c++·算法
-dzk-1 天前
【代码随想录】LC 59.螺旋矩阵 II
c++·线性代数·算法·矩阵·模拟
m0_706653231 天前
C++编译期数组操作
开发语言·c++·算法
qq_423233901 天前
C++与Python混合编程实战
开发语言·c++·算法
m0_715575341 天前
分布式任务调度系统
开发语言·c++·算法
CSDN_RTKLIB1 天前
简化版unique_ptr说明其本质
c++