hdu 1391 Number Steps(规律)

题意:找规律

思路:找规律

#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int n,x,y;
    scanf("%d",&n);
    while(n--){
        scanf("%d%d",&x,&y);
        if(x==y)x&1?printf("%d\n",x+x-1):printf("%d\n",x+x);
        else if(x-y==2)x&1?printf("%d\n",x+y-1):printf("%d\n",x+y);
        else printf("No Number\n");
    }
    return 0;
}

时间: 2024-10-31 13:53:56

hdu 1391 Number Steps(规律)的相关文章

HDU 4952 Number Transformation 规律题

打表可以知道到后面增量都一样了,, 推论就是  i 和 i+1 互质 #include <cstdio> #include <algorithm> #include <cstring> #include <iostream> using namespace std; typedef long long ll; const ll mx = 120000; int main() { int cas = 0; ll x, k, y, dis, i; while (

杭电 HDU ACM 1391 Number Steps

Number Steps Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4376    Accepted Submission(s): 2656 Problem Description Starting from point (0,0) on a plane, we have written all non-negative inte

HDOJ 1391 Number Steps(打表DP)

Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers 0, 1, 2,- as shown in the figure. For example, 1, 2, and 3 has been written at points (1,1), (2,0), and (3, 1) respectively and this pattern has conti

hdu 4952 Number Transformation (找规律)

题目链接 题意:给你个x,k次操作,对于第i次操作是:要找个nx,使得nx是>=x的最小值,且能整除i,求k次操作后的数 分析: 经过打表找规律,会发现最后的x/i,这个倍数会趋于一个固定的值,求出这个固定的值和K相乘就可以了, 为什么会趋于固定的值呢,因为最后虽然i在不断增长,但是x也是在增长的,每次的倍数会回退一个发现 有余数,然后再加上一个,所以趋于稳定. 官方题解: 1 #include <iostream> 2 #include <cstdio> 3 #includ

HDU 4279 Number 规律题

题意: 定义函数F(x) : 区间[1,x]上的y是满足:GCD(x,y)>1 && x%y>0的 y的个数. 问:对于任意区间[l,r] 上的F(l···r) 有几个函数值是奇数的. 打表找规律. 打的是[1,x]区间的结果 把所有结果不相同的值打出来(因为结果是递增的,所以只观察不相同的结果) 发现:ans = x/2-2 || x/2-1 再把所有结果不同 && x/2-1的值打出来 发现 sqrt(x) &1 == 1 得到:ans = x/2-

HDU 1005 Number Sequence (数学规律)

Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 104190    Accepted Submission(s): 25232 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A

HDU 4952 Number Transformation 打表规律

点击打开链接 Number Transformation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 495    Accepted Submission(s): 248 Problem Description Teacher Mai has an integer x. He does the following operation

HDU 4952 Number Transformation 多校8 机智数学

哎.这个题想了好久,状态不对啊...一个大家都出的题..当时想到肯定是可以有什么规律来暴力,不用算到10的10次方 对于某个k,x.从1到k循环,每次求一个新的x,这个x要大于等于原x,并且要是i的倍数... 一直觉得有规律可循,后来知道就是倍数,我们设倍数为 b, 则b2*(i+1)>=b1*(i);可以知道b2>=b1-b1/(i+1),则,b2在b1小于等于i+1的时候便不会再变换,题目最大的倍数为10的10次方,根据第一个式子,最多经过10的五次方,倍数就会缩为10的五次方,此时i也&

HDU 1005 Number Sequence(数论)

HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n). Input The input consists of multiple