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. 在 Windows Azure 虚拟机中如何备份和还原 Windows 系统磁盘

    备份和还原对于操作真实的系统来说至关重要.对于 Windows Azure 虚拟机环境中的 Windows Server,可以根据自身的需求选择多种不同的工具或将这些工具结合使用来实现备份.下面将对这 ...

  2. 深入分析MFC文档视图结构(项目实践)

    k_eckel:http://www.mscenter.edu.cn/blog/k_eckel 文档视图结构(Document/View Architecture)是MFC的精髓,也是Observer ...

  3. TraceView简单使用方法

    一.TraceView简介 TraceView是AndroidSDK里面自带的工具,用于对Android的应用程序以及Framework层的代码进行性能分析. TraceView是图形化的工具,最终它 ...

  4. new Date().getTime()

    new Date().getTime()获取当前时间戳; 不知道是毫秒级还是千分之一毫秒级别

  5. cf-A. Wet Shark and Odd and Even(水)

    A. Wet Shark and Odd and Even time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  6. xcode UIImage图片拉伸

    图片拉伸 +(UIImage*)wlisWithImage:(NSString *)name{ //获取图片 UIImage * img=[UIImage imageNamed:name]; //获取 ...

  7. sql server group by having 之复习篇

    where 与 having 之间的差别在于where 是分组前的过滤,而having是分组后的过滤 Group By中Select指定的字段限制 示例3 select 类别, sum(数量) as ...

  8. js简繁转换,两种实现方式,妥妥的~

    不知道繁简按钮有什么卵用,大陆人自带繁简转换开关的好么,但是还是项目要求,做了这么一个功能,现在整理给大家用~完美兼容~么么哒 按钮的样式可以随便用css定义,注意id不要变,注意jq的事件绑定好就o ...

  9. GridView隔行样式

    <AlternatingRowStyle BorderColor="#FF99CC" BorderStyle="Solid" />

  10. Openv2.1基本数据类型

    1.Point_ template<typename _Tp> class Point_ {_Tp x, y;} 可使用的运算: pt1 = pt2 + pt3; pt1 = pt2 - ...