SDUT 1068-Number Steps(数学:直线)
Number Steps
Time Limit: 1000ms Memory limit: 10000K 有疑问?点这里^_^
题目描写叙述

You are to write a program that reads the coordinates of a point (x, y), and writes the number (if any) that has been written at that point. (x, y) coordinates in the input are in the range 0...5000.
输入
输出
演示样例输入
3
4 2
6 6
3 4
演示样例输出
6
12
No Number
就是按图中的规律给出两条直线。。 我一開始竟然没看出来是直线。。找规律打表敲了一大片结果wa了,后来发现就是推断点是否在直线上嘛 两条直线分别为y=x与y=x-2; 然后那个编号能够依据坐标x写出相应关系,非常好写,都是等差数列。我是分奇偶讨论的。。
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#define ll long long
using namespace std;
const int INF=1<<27;
const int maxn=1010;
int main()
{
int x,y,n;
scanf("%d",&n);
while(n--)
{
scanf("%d%d",&x,&y);
if(x==y)
{
if(x%2)
printf("%d\n",2*x-1);
else
printf("%d\n",2*x);
}
else if(y==x-2)
{
if(x%2)
printf("%d\n",2*x-3);
else
printf("%d\n",2*x-2);
}
else
puts("No Number");
}
return 0;
}
SDUT 1068-Number Steps(数学:直线)的更多相关文章
- HDU-1391 Number Steps
http://acm.hdu.edu.cn/showproblem.php?pid=1391 Number Steps Time Limit: 2000/1000 MS (Java/Others) ...
- Number Steps
Number Steps Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- ZOJ 1414:Number Steps
Number Steps Time Limit: 2 Seconds Memory Limit: 65536 KB Starting from point (0,0) on a plane, ...
- POJ 1663:Number Steps
Number Steps Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13758 Accepted: 7430 Des ...
- POJ 1663:Number Steps
Number Steps Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13664 Accepted: 7378 Des ...
- HDU 1391 number steps(找规律,数学)
Starting from point (0,0) on a plane, we have written all non-negative integers 0, 1, 2,... as shown ...
- SDUT 3258 Square Number 简单数学
和上一题一样,把平方因子除去,然后对应的数就变成固定的 #include <cstdio> #include <iostream> #include <algorithm ...
- SDUT 3257 Cube Number 简单数学
把所有数的立方因子除去,那么一个数可以和它组成立方的数是确定的,统计就行 #include <cstdio> #include <iostream> #include < ...
- hdu1391(Number Steps )
Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers ...
- HDU 1018-Big Number(数学)
Big Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
随机推荐
- Unity3D - UGUI的初级应用
添加字体: 把下载好的字体拖拽到Project面板中 - 点击Text组件中Text属性后面的圆点 - 选择刚刚拖拽的字体即可. 创建ToggleGroup(开关组): 1.在Canvas下创建两个T ...
- curl保存图片
$url = 'http://p1.qhimg.com/t013dfc89f8a039122c.jpg?size=690x460'; function http_get_data($url) { $c ...
- 解决 Could not load hsdis-amd64.dll
win10下想查看JIT编译的汇编源码 结果提示: Could not load hsdis-amd64.dll; library not loadable; PrintAssembly is dis ...
- aoj 2226 Merry Christmas
Merry Christmas Time Limit : 8 sec, Memory Limit : 65536 KB Problem J: Merry Christmas International ...
- JS判断SharePoint页面编辑状态
这篇博客主要讲使用不同的客户端方式来判断页面的编辑模式. 1.当页面处于发布状态时,可以使用下面两种方式:if(g_disableCheckoutInEditMode == true) { ale ...
- net2:DropDownList的使用
原文发布时间为:2008-07-29 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Data;using System.Configuration ...
- 如何用DW设计界面 结合 VS设计后台代码
原文发布时间为:2008-11-02 -- 来源于本人的百度文章 [由搬家工具导入] 问:在vs.net里有form标记,而dw里却没有,两个里面的标记代码都不一样,怎么能通用? 在.net里修改dw ...
- C语言处理json字符串
JSON语法说明 先来看一个简单的JSON 1 { 2 "stars": [ 3 { 4 "name": "Faye", 5 "a ...
- Android Studio 快捷键整理分享-SadieYu
文章编辑整理:Android Studio 中文组 - SadieYu Alt+回车 导入包,自动修正 Ctrl+N 查找类 Ctrl+Shift+N 查找文件 Ctrl+Alt+L 格式化代码 ...
- 现象: shell脚本中source aaa.sh时提示 source: not found
原因: ls -l `which sh` 提示/bin/sh -> dash 这说明是用dash来进行解析的. 改回方法: 命令行执行:sudo dpkg-reconfigure dash 在界 ...