The Bells are Ringing UVALive - 4060(枚举求解)
输出整数N,使得 t1 <= N 统计有多少组t1,t2,t3,满足:1<t1<t2<t3<=1000000,t3-t1<=25,且t1,t2,t3的最小公倍数是N
枚举t1就好了
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = ; LL gcd(LL a, LL b)
{
return b==?a:gcd(b, a%b);
} int main()
{
LL n;
int kase = ;
while(scanf("%lld",&n) != EOF && n)
{
int ok = ;
printf("Scenario %d:\n",++kase);
for(LL i=; i<=n && i<=maxn; i++)
{
if(n % i) continue;
for(LL j=i+; j<=i+ && j<=maxn; j++)
{
if(n % j) continue;
LL tem1 = i * j / gcd(i, j);
for(LL k=j+; k<=i+ && k <= maxn; k++)
{
if(n % k) continue;
LL tem2 = tem1 * k / gcd(tem1, k);
if(tem2 == n)
{
printf("%lld %lld %lld\n",i,j,k);
ok = ;
}
}
}
}
if(!ok) printf("Such bells don't exist\n"); printf("\n"); } return ;
}
The Bells are Ringing UVALive - 4060(枚举求解)的更多相关文章
- The Bells are Ringing(枚举)
Description Perhaps you all have heard the mythical story about Tower of Hanoi (The details of this ...
- UVA - 12119 The Bells are Ringing (枚举)
Perhaps you all have heard the mythical story about Tower of Hanoi (The details of this story is not ...
- zoj 1008 暴力枚举求解dfs+优化
/* 现将相同的合并计数. 再枚举判断是否符合当cou==n*n是符合就退出 */ #include<stdio.h> #include<string.h> #define N ...
- POJ1288 Sly Number(高斯消元 dfs枚举)
由于解集只为{0, 1, 2}故消元后需dfs枚举求解 #include<cstdio> #include<iostream> #include<cstdlib> ...
- poj 2992 Divisors (素数打表+阶乘因子求解)
Divisors Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9617 Accepted: 2821 Descript ...
- Avito Cool Challenge 2018 E. Missing Numbers 【枚举】
传送门:http://codeforces.com/contest/1081/problem/E E. Missing Numbers time limit per test 2 seconds me ...
- .Uva&LA部分题目代码
1.LA 5694 Adding New Machine 关键词:数据结构,线段树,扫描线(FIFO) #include <algorithm> #include <cstdio&g ...
- [学习笔记] 舞蹈链(DLX)入门
"在一个全集\(X\)中若干子集的集合为\(S\),精确覆盖(\(\boldsymbol{Exact~Cover}\))是指,\(S\)的子集\(S*\),满足\(X\)中的每一个元素在\( ...
- Beauty Contest
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=28417#problem/F 题目大意:给n个点,求相聚最远距离的平方(输出整形) 集体思 ...
随机推荐
- vue组件--通讯录
简介 在移动端开发中,通讯录是个很常见的需求. 通讯录通常要实现以下功能 首字母导航 滚动到一定位置首字母固定 在线通讯录demo 布局 通讯录是典型的上下两栏布局,上面是header,下面是内容区, ...
- 【Unity Shader】(四) ------ 纹理之法线纹理、单张纹理及遮罩纹理的实现
笔者使用的是 Unity 2018.2.0f2 + VS2017,建议读者使用与 Unity 2018 相近的版本,避免一些因为版本不一致而出现的问题. [Unity Shader](三) ----- ...
- 在vsphere6.5启用Tesla K80
基础环境: vsphere6.5 VMware vCenter6.5 宝德服务器2750S Tesla K80 0x01 选择主机,配置→硬件→PCI设备→添加K80显卡 注意:1.添加完显卡后,主机 ...
- L2 Helios OPcodez
天堂2 Helios太阳神版本 的客户端和服务端封包 *********************** Client ***********************00 SendLogOut01 Req ...
- 买卖股票的最佳时机 II
int maxProfit(int* prices, int pricesSize) { ; ; i < pricesSize - ; i++) { ]) { continue; } else ...
- 炸!分享美团面试关于selenium的面试题
个人分类: 软件测试 编辑 在这个互联网技术快速迭代的时代,每个测试员都知道技术对于职业发展的重要性,那些技术好的测试员不仅薪资高,而且大多数集中在一线互联网企业工作,让人感觉非常高大上的同时,也想去 ...
- AttributeError: module ‘tensorflow.python.ops.nn’ has no attribute ‘leaky_relu’
#AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu' 的原因主要是版本的问题 解决方法是更新 ...
- HDU3629(凸四边形的个数)
HDU 3629 计算几何 题目描述:给你n个点(4~700), 问你能够成多少个不同的凸四边形. 解题报告: 暴力的话C(700,4)必然超时,发现,任何一个凹包必然是其中一点在其它3点构成的三角形 ...
- Alpha 冲刺报告3
队名 massivehard 组员一(组长:晓辉) 今天完成了哪些任务 .整理昨天的两个功能,补些bug 写了一个初步的loyaut github 还剩哪些任务: 后台的用来处理自然语言的服务器还没架 ...
- alphe4
队名:massivehard 组员1:(组长:晓辉) 今天完成了哪些任务: 服务器基本架设完毕 明日计划: 服务器与客户端对接 用户手写记录功能的完善 还剩下哪些计划: 用户手写记录功能 服务器与客户 ...