Last Defence (run time error)
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)的更多相关文章
- Flutter采坑之路 Run Configuration error:broken configuration due to unavailable
今天把AndroidStudio升级成了3.3.1 原先还能编译成功的Flutter工程突然连编译都不行了, 错误是 Run Configuration error:broken configurat ...
- 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 ...
- 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 ...
- 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 ...
- Run Configuration error:broken configuration due to unavailable
希望大家一起来,毕竟大家都不会使用这个Androidstudio,一起扩展这方面的知识量 http://forums.opengamma.com/t/intellij-code-compiles-bu ...
- 一次lr异常Error: C interpreter run time error: Action.c (17): Error -- memory violation : Exception ACCESS_VIOLATION received问题分析
今天qq群里人问我一个问题 人家的原始问题如下: 问题是为啥通过lr_save_string取不到参数值 由于别的问题,我也需要调试,但是没有环境,只能模拟场景,如下 他想将token变量换成lr中的 ...
- npm run dev error
Please try: rm -rf node_modules rm package-lock.json npm cache clear --force npm install windows和lin ...
- 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 ...
- 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 ...
随机推荐
- Cppcheck软件使用
一款开源源码检测工具.简单易用. 官网网址:http://cppcheck.sourceforge.net/ 软件可直接官网下载. [plain] view plaincopy Features Ou ...
- MongoDB Error
①,org.springframework.core.convert.ConverterNotFoundException: No converter found capable of con ...
- paip.c++ qt messagebox用法
paip.c++ qt messagebox用法 作者Attilax , EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csdn.net ...
- 【百度地图API】获取行政区域的边界
);map.addControl(new BMap.NavigationControl({type: BMAP_NAVIGATION_CONTROL_SMALL}));map.enableScroll ...
- FINDPEAKS - matlab函数
FINDPEAKS Find local peaks in data PKS = FINDPEAKS(X) finds local peaks in the data vector X. A loca ...
- python 格式化日期
#!/usr/bin/env pythonimport sysimport reimport datetime dd = '2014-08-10'da = datetime.datetime.strp ...
- P - Shopaholic
P - Shopaholic Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Submit ...
- 百度editor调用【图片上传阿里云】
百度editor调用简单,但是图片和文件上传阿里云就有点难度了.下面我详细说一下. 百度富文本编辑器下载地址:http://ueditor.baidu.com/website/download.htm ...
- css如此强大你知道吗
看个这个大神纯 CSS 绘制<辛普森一家>人物头像我惊呆了,css如此牛x <div id="wrap"> <div class="cont ...
- C#学习日志 day 5 ------ windows phone 8.1真机调试手机应用
在vs2013中,可以写windows phone 8.1的程序,但是调试时需要用到windows自带的虚拟机hyper-V 正版的系统开启hyper—V的时候不会有问题,但是盗版的系统可能导致系统不 ...