Last Defence
时间限制:1000 ms | 内存限制:65535 KB
描述
Given two integers A and B. Sequence S is defined as follow:
• S0 = A
• S1 = B
• Si = |Si-1 – Si-2| for i ≥ 2
Count the number of distinct numbers in S .
输入
The first line of the input gives the number of test cases, T. T test cases follow. T is about 100000.
Each test case consists of one line – two space-separated integers A, B. (0 ≤ A, B ≤ 10^18).
输出
For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is the number of distinct numbers in S .
样例输入
2
7 4
3 5
样例输出
Case #1: 6
Case #2: 5
来源
Yougth
我的思路:首先这道题run time error了。。任何两个数,进行题中的运算,得出是一组数,最后肯定是x, x,0,x,x,0,x,x,0……循环的,所以当遇到x,x,0时候就停止,然后把前面的数和x,0进行处理,计算一下一共有多少不同的数。。希望大家帮看一下,这个代码运行没有错误,结果也对。
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cmath>
using namespace std;
int a[];
int main()
{
int T,i,j;
int g=;
long long A,B;
cin>>T;
while(T--)
{
scanf("%lld%lld",&A,&B);
a[]=A;
a[]=B;
i=;
while()
{
a[i]=fabs(a[i-]-a[i-]);
a[i+]=fabs(a[i]-a[i-]);
a[i+]=fabs(a[i+]-a[i]);
if(a[i]==a[i+]&&a[i+]==)
{ a[i+]=;
break;
}
i++;
}
int n=i+;
sort(a,a+i+);
for(i=;i<n-;i++)
{
if(a[i]==a[i+])
{
for(j=i;j<n-;j++)
a[j]=a[j+];
i--;
n--;
}
}
printf("Case #%d: %d\n",g,n);
g=g+;
}
return ;
}
												

Last Defence (run time error)的更多相关文章

  1. Flutter采坑之路 Run Configuration error:broken configuration due to unavailable

    今天把AndroidStudio升级成了3.3.1 原先还能编译成功的Flutter工程突然连编译都不行了, 错误是 Run Configuration error:broken configurat ...

  2. LR 报错误: C interpreter run time error: Error -- Unresolved symbol : vuser_end解决方法

    Action.c(33): Error: C interpreter run time error: Action.c (33):  Error -- Unresolved symbol : vuse ...

  3. Unexpected exception 'Cannot run program ... error=2, No such file or directory' ... adb'

    Eclipse ADT Unexpected exception 'Cannot run program' up vote 8 down vote favorite 4 I have installe ...

  4. Android Studio2.1 Run APP:Error: Execution failed for task

    Android Studio2.1 Run APP时,遇到错误 Error: Execution failed for task ':app:clean'. Unable to delete file ...

  5. Run Configuration error:broken configuration due to unavailable

    希望大家一起来,毕竟大家都不会使用这个Androidstudio,一起扩展这方面的知识量 http://forums.opengamma.com/t/intellij-code-compiles-bu ...

  6. 一次lr异常Error: C interpreter run time error: Action.c (17): Error -- memory violation : Exception ACCESS_VIOLATION received问题分析

    今天qq群里人问我一个问题 人家的原始问题如下: 问题是为啥通过lr_save_string取不到参数值 由于别的问题,我也需要调试,但是没有环境,只能模拟场景,如下 他想将token变量换成lr中的 ...

  7. npm run dev error

    Please try: rm -rf node_modules rm package-lock.json npm cache clear --force npm install windows和lin ...

  8. Proxy account failing to run SSIS Error (Proxy (11) is not allowed for subsystem "SSIS" and user "AB\testuser ".

    USE [msdb]EXEC msdb.dbo.sp_grant_login_to_proxy @proxy_name=N'SSISProxyAgentV1', @login_name=N'WTC\E ...

  9. laravel npm run dev 错误 npm run dev error [npm ERR! code ELIFECYCLE]

    出现此问题是node_modules出现错误,需要执行: 1 rm -rf node_modules 2 rm package-lock.json 3 npm cache clear --force ...

随机推荐

  1. mysql binlog 混合模式 出现的基于sql的数据不一致,主要是now()这类函数导致

  2. [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(一)

    目的: 结合现在比较流行的技术,通过一个demo 展示一个全栈式设计的各种技能. 一个全栈式的工程师,应该能设计通过verilog/VHDL做logical设计.能写内核驱动,能架站. 要熟悉veri ...

  3. 面向对象程序设计-C++_课时22向上造型

    赋值兼容规则是指在公有派生情况下,一个派生类的对象可以作为基类的对象来使用的情况. 约定类derived是从类base公有派生而来的,则指如下3种情况: (1)派生的对象可以赋给基类的对象.例如: d ...

  4. Roland钢琴开发中音符值、度、与音名之间的转换算法

    在Roland钢琴伴侣的开发中,首先将mid文件解析出来取到每一个音符的起始时间,每一个音符的时值,音符值(比如中央C的值是60),在绘五线谱的时候需要将每一个音符值与它对应的度(octave)和音名 ...

  5. Swift初体验(三)

    /*******************************************************************************/ // 协议 protocol Des ...

  6. Ubuntu下屏幕录像、后期处理不完全攻略

    提要 如果要做成果展示或者效果演示,通常需要录取屏幕生成视频文件,在windows中我们可以用屏幕录像专家在录像, vegas 来做后期处理,Ubuntu可以么? 答案时当然可以!虽然第一次用觉得有点 ...

  7. Sicily 4495. Print permutations

    http://soj.me/4495 按字典序生成字符串的全排列 直接递归: #include <iostream> #include <string> #include &l ...

  8. 662 - Fast Food

    描述:状态方程p[i][j]=dp[i-1][k]+dist(k+1,j),由于没搞懂距离dist是怎么计算的,以为是num[j]-num[k+1],结果wa了一次,在状态转移的时候,采用一个数组sc ...

  9. javascript 的加载方式

    本文总结一下浏览器在 javascript 的加载方式. 关键词:异步加载(async loading),延迟加载(lazy loading),延迟执行(lazy execution),async 属 ...

  10. English - according to 的用法说明

    1. 用于according to,意为“根据”,为复合介词,后接名词或代词.注意以下用法: (1) 主要用来表示“根据”某学说.某书刊.某文件.某人所说等或表示“按照”某法律.某规定.某惯例.某情况 ...