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;
}
相关推荐
feng_you_ying_li12 小时前
C++复习二,继承与多态
c++
小小de风呀12 小时前
de风——【从零开始学C++】(十一):list的基本使用和模拟实现
开发语言·c++·list
陌路2012 小时前
C++高级进阶--夯实进阶基础(1)
开发语言·c++
郝学胜-神的一滴13 小时前
中级OpenGL教程 008:精准控制高光光斑大小与强度
c++·unity·godot·three.js·图形学·opengl·unreal
牢姐与蒯14 小时前
c++数据结构之c++11(一)
数据结构·c++
折戟不必沉沙14 小时前
构造和析构函数能否是虚函数?能否调用虚函数?
c++
-To be number.wan14 小时前
算法日记 | STL- sort排序
c++·算法
不想写代码的星星14 小时前
编译期策略模式:当模板成为策略容器
c++
啦啦啦啦啦zzzz14 小时前
数据结构:平衡二叉树
数据结构·c++·二叉树
玖釉-14 小时前
Vulkan 中 Shader 的 vert、frag、mesh、comp 全面解析:作用、关系、特点与工程实践
开发语言·c++·windows·算法·图形渲染