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个点,求相聚最远距离的平方(输出整形) 集体思 ...
随机推荐
- 电商打折套路分析 —— Python数据分析练习
电商打折套路分析 ——2016天猫双十一美妆数据分析 数据简介 此次分析的数据来自于城市数据团对2016年双11天猫数据的采集和整理,原始数据为.xlsx格式 包括update_time/id/tit ...
- Linux(centos7)之更换安装python3(二)
Linux不比window好安装python,折腾了好久,终于成功安装上了python,window上一个安装包完事,可惜Linux上python版本太低不好使,还要更换为3版本,百度了好久,教程上总 ...
- 机器学习基础 --- numpy的基本使用
一.numpy的简介 numpy是Python的一种开源的数值计算扩展库.这种工具可用来存储和处理大型矩阵,比Python自身的嵌套列表(nested list structure)结构要高效的多(该 ...
- spring-boot+swagger实现WebApi文档
1.引用依赖包 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-s ...
- chown命令详情
基础命令学习目录首页 原文链接:https://www.jb51.net/article/98255.htm chown将指定文件的拥有者改为指定的用户或组,用户可以是用户名或者用户ID:组可以是组名 ...
- 团队项目M1阶段个人反思
郑培蕾: 作为项目的PM,我前期的工作还是有很大的缺陷的,因为没有在开发之前对项目进行一个合理的评估,所以后来分配任务的时候就很不科学, 而且任务分配的比较粗糙,没有细化到每个人每天应该做什么,这就导 ...
- 团队项目-北航MOOC系统Android客户端 NABC
北航MOOC系统Android客户端 NABC (N) Need 需求 MOOC的全名是Massive Open Online Course,被称作大型开放式网络课程.2012年,美国的顶尖大学陆续设 ...
- 每日scrum(1)
今天又正式开始了第二个冲刺周期,计划十天,主要需要改进的地方包括UI界面,还有一些细节的把握. 今天出现的主要问题有:在讨论UI界面风格的时候,小组内部意见不统一,对UI界面的创作流程不熟悉,以及难度 ...
- python接口测试之requests库(一)
一.requests库的安装 requests库作为第三方库,需要安装 cmd模式下,运行pip install requests 二.在学习如何发送请求之前,我们先来了解一下requests库,查看 ...
- Java编程题每日一练day1
Day1共7题 package com.pcx.day1; /** * 设一个字符数组,对其元音字母进行统计 * a e i o u * @author Administrator * */ publ ...