ACDream 1408 "Money, Money, Money" (规律)

"Money, Money, Money"

Special Judge Time Limit: 2000/1000MS (Java/Others)

Memory Limit: 128000/64000KB (Java/Others)

Submit Statistic Next Problem

Problem Description

The government of Flatland has decided to carry out the money system reform. The purpose of the reform is to reduce the number of different banknotes denominations down to two. After the reform there will be two types of banknotes — a tupiks and b tupiks.
      The problem is that the president of Flatland doesn’t like the number x. Therefore the minister of finances was instructed to choose such a and b that it is impossible to pay exactly x tupiks without change. On the other hand it must be possible to pay all amounts larger than x.
      Now you are asked to help him — choose such a and b, or recommend the minister to retire, if it is impossible.

Input

Input file contains one number x (1 ≤ x ≤ 1012).

Output

Output two integer numbers a and b, such that it is impossible to pay x tupiks using banknotes of a and b tupiks without change, but it is possible to pay any larger sum. If it is impossible, output two zeroes to the output file.

Sample Input

3
4
5

Sample Output

2 5
0 0
3 4

Source

Andrew Stankevich Contest 21

题意:找到两个数,使得其能够组成大于x的所有数字

分析:这道题如果x是偶数,小数据模拟了一下发现是无解的,x是奇数的话那么大于x的数字可以由2和x+2组成。

至于为什么x是偶数时是无解还是没有推出来,过往大牛看到解答一下~

#pragma comprint(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<stdlib.h>
#include<time.h>
#include<algorithm>
#define LL long long
#define FIN freopen("in.txt","r",stdin)
using namespace std;
int main()
{
    LL x;
    while(scanf("%lld",&x)!=EOF)
    {
        if(x&1)
            printf("2 %lld\n",x+2);
        else
            printf("0 0\n");
    }
    return 0;
}

时间: 2024-12-15 08:36:07

ACDream 1408 "Money, Money, Money" (规律)的相关文章

16.05.25-16.06.10 题集

继2016.05.24续: codeforces 651B. Beautiful Paintings-简单 http://codeforces.com/problemset/problem/651/B 大意:给出一个序列,求解其任意排列中满足ai?+?1?>?ai 的元素个数最大和. 分析:理想情况下,无重复元素的0从小到大的排列,满足条件的元素个数最多,是n-1. 非理想情况下还有重复元素,只要不断提取出重复的这些元素归到另一集合再这样讨论即可. #include <iostream>

Acdream 1210 Chinese Girls&#39; Amusement(大数模板运算 + 找规律)

传送门 Chinese Girls' Amusement Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description You must have heard that the Chinese culture is quite different from that of Europe or Rus

ACdream 1213 Matrix Multiplication【水题 、 找规律】

Matrix Multiplication Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) 链接:http://acdream.info/problem?pid=1213 Problem Description Let us consider undirected graph G = {V; E} which has N vertices and M edges. Incidence

acdream 1210 Chinese Girls&#39; Amusement (打表找规律)

题意:有n个女孩围成一个圈从第1号女孩开始有一个球,可以往编号大的抛去(像传绣球一样绕着环来传),每次必须抛给左边第k个人,比如1号会抛给1+k号女孩.给出女孩的人数,如果他们都每个人都想要碰到球一次,那么这个k应该是多少(满足 1 ≤ K ≤ N/2 且 k必须尽量大)?   例如:n=7,那么1号开始拿球,抛球的顺序是 1, 4, 7, 3, 6, 2, 5, 1.  当球重新回到1女孩手中时,每个人刚好只玩了一次.注:这个数字相当大(3 ≤ N ≤ 102000) 思路: 方法(1): 暴

Acdream 1115——找规律——Salmon And Cat

Math is very important, for those who are also in school, make sure you will learn more about math. Salmon and Cat are good friends.Today Salmon ask Cat to help her judge whether a number is perfect or not. Perfect number is a kind of number defined

Acdream 1416 Crazy Nim(简单博弈找规律)

传送门 Crazy Nim Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description Alice and Bob like to play crazy nim. The game proceeds as follows. There are several stones arranged in

ACdream 1115 Salmon And Cat (找规律&amp;amp;&amp;amp;打表)

题目链接:传送门 题意: 一个数被觉得是一个完美的数,仅仅要须要满足下面的两个条件之中的一个 1)x = 1 or 3 2)x = 2 + a*b + 2*a + 2*b; a.b都是完美的数. 分析: x + 2 = (a + 2)*(b + 2) 因为x1=1,x2=3.全部的数都是由着两个数衍生而来.那么我们就可 以得出一个结论了.一个数x假设是完美的数.那么x = 3^p*5^q; 因此代码例如以下: #include <iostream> #include <cstdio>

ACdream 1115 Salmon And Cat (找规律&amp;&amp;打表)

题目链接:传送门 题意: 一个数被认为是一个完美的数,只要需要满足以下的两个条件之一 1)x = 1 or 3 2)x = 2 + a*b + 2*a + 2*b; a,b都是完美的数. 分析: x + 2 = (a + 2)*(b + 2) 由于x1=1,x2=3,所有的数都是由着两个数衍生而来.那么我们就可 以得出一个结论了,一个数x如果是完美的数,那么x = 3^p*5^q; 因此代码如下: #include <iostream> #include <cstdio> #inc

ACdream原创群赛(13)のwuyiqi退役专场 F The Arrow

F 首先是要理解概率求期望这种题目是用递归来解的! 大概规律就是: 完成事件A的期望是Ea,一次完成的概率是pa,那么 Ea = pa * Ea + (1 + Ea) * (1 - pa) 如果有好多种可能,比方说完成一个事件A的同时,也有诸如事件B的概率期望pb,Eb,事件C的概率期望pc,Ec等等等等,那么就分别写出来: Ea = pa * Ea + (1 + Ea) * (~pa) + pb * (1 + Eb) + pc * (1 + Ec) + ... 其中~pa是除了这些已知的事件发