FZU 2147 A-B Game

我们只需要知道这个取完模最大是 a / 2 + 1就可以了,不过超时了几次,换了visual C++才过,oj还真是傲娇啊.

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int t;
    long long a,b;
    int ca = 0;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lld %lld",&a,&b);
        int tot = 0;
        while(a > b)
        {
            a = a/2 + 1;
            tot++;
        }
        printf("Case %d: %d\n",++ca,tot);
    }
    return 0;
}
时间: 2024-10-21 17:04:18

FZU 2147 A-B Game的相关文章

FZU 2147(数学,规律)

Problem 2147 A-B Game Accept: 1202    Submit: 2853 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Fat brother and Maze are playing a kind of special (hentai) game by two integers A and B. First Fat brother write an integer A on

FZU - 2147 A-B Game(找规律)

A-B Game Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit Status Description Fat brother and Maze are playing a kind of special (hentai) game by two integers A and B. First Fat brother write an integer A on a white p

FZU OJ 2147 A-B Game (数学水题)

Problem 2147 A-B Game Accept: 827    Submit: 1940 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Fat brother and Maze are playing a kind of special (hentai) game by two integers A and B. First Fat brother write an integer A on

Problem 2147 A-B Game (数学啊)

题目链接:http://acm.fzu.edu.cn/problem.php?pid=2147 Problem Description Fat brother and Maze are playing a kind of special (hentai) game by two integers A and B. First Fat brother write an integer A on a white paper and then Maze start to change this int

FZU 2150 Fire Game(点火游戏)

p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-size: 10.5000pt } h2 { margin-top: 5.0000pt; margin-bottom: 5.0000pt; text-align: left; font-family: 宋体; font-weight: bold; font-size: 18.0000pt } h3 {

FZU 1096 QS Network

QS Network Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original ID: 1096 64-bit integer IO format: %I64d      Java class name: Main In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS.

FZU 1759 欧拉函数 降幂公式

Description Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000000000,1<=B<=10^1000000). Input There are multiply testcases. Each testcase, there is one line contains three integers A, B and C, separated by a singl

ACM: FZU 2150 Fire Game - DFS+BFS+枝剪 或者 纯BFS+枝剪

FZU 2150 Fire Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid of this boar

FZU 2112 并查集、欧拉通路

原题:http://acm.fzu.edu.cn/problem.php?pid=2112 首先是,票上没有提到的点是不需要去的. 然后我们先考虑这个图有几个联通分量,我们可以用一个并查集来维护,假设有n个联通分量,我们就需要n-1条边把他们连起来. 最后对于每个联通分量来说,我们要使它能一次走完,就是要求他是否满足欧拉通路,也就是这个联通分量中至多有2个度为奇数的点,每多出2个度为奇数的点,就多需要一条边(因为单个连通分量的所有点的度数之和为偶数,所以不可能存在奇数个奇数度数的点). 1 #i