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个点,求相聚最远距离的平方(输出整形) 集体思 ...
随机推荐
- redis中key的归类
redis中可以使用前缀对key进行归类: 例如:key: ITEM_INFO:123456:BASE ITEM_INFO:123456:DESC 作用:方便进行管理 如果把二维表保存到redis中: ...
- SpringCloud使用Feign出现java.lang.ClassNotFoundException: org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory异常
废话不多说!!! 在SpringCloud项目中配置了Feign来调用restful接口,项目启动的时候报错,报错信息如下: 找不到org.springframework.cloud.client.l ...
- 使用tensorflow进行mnist数字识别【模型训练+预测+模型保存+模型恢复】
import sys,os sys.path.append(os.pardir) import numpy as np from tensorflow.examples.tutorials.mni ...
- MAVEN项目导入src/test/java项目报错
转载博客:https://blog.csdn.net/gengjianchun/article/details/78679036 https://blog.csdn.net/jsloveyou/ ...
- 六大iT公司的组织结构
- Hyperledger Fabric CA User’s Guide——开始(三)
Fabric CA User’s Guide——开始 先决条件 安装Go 1.9+ 设置正确的GOPATH环境变量 安装了libtool和libtdhl-dev包 下面是在Ubuntu上安装libto ...
- 关于几个与IO相关的重要概念
1.读/写IO 读IO就是发指令从磁盘读取某段序号连续的扇区内容.指令一般是通知磁盘开始扇区位置,然后给出需要从这个初始扇区往后读取的连续扇区个数,同时给出动作是读还是写.磁盘收到这条指令就会按照指令 ...
- excel窗口独立显示/单独显示
天赋异禀的亲,一看就懂!
- Python常用模块之PIL(手册篇:Image模块)
官方手册地址:http://effbot.org/imagingbook/image.htm Image模块 图像模块提供了一个具有相同名称的类,用于表示一个PIL的图像.该模块还提供了许多功能,包 ...
- Vs2012 编写代码规则
FxCop编写规则 VS2012 下更方便,所需的DLL在: D:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Static ...