Problem F
来源:互联网 发布:java实现99乘法表 编辑:程序博客网 时间:2024/04/29 09:04
找数列规律~
#include <iostream>#include <cstdio>#include <queue>#include <cstring>#include <cmath>#include <vector>#include <iomanip>#include <algorithm>//#include "myAlgorithm.h"#define MAXL 1000005#define INF 1e8using namespace std;int n;int a[MAXL];int partion(int low, int high){ int key = a[low]; while(low < high){ while(low < high && key <= a[high]){ high--; } swap(a[low], a[high]); while(low < high && key >= a[low]){ low ++; } swap(a[low], a[high]); } return low;}void quickSort(int low, int high){ if(low < high){ int mid = partion(low, high); quickSort(low, mid -1); quickSort(mid + 1, high); }}int main(){ ///freopen("in.txt","w",stdout); /* while( cin>>n){ for(int i = 0; i < n; i++){ scanf("%d", &a[i]); } quickSort(0, n -1); cout<<a[n/2]<<endl; }*/ int k; cin>>k; int x, y; while(k--){ cin>>x>>y; int ans; if(x == y ){ if(x%2==0){ ans = 4 * x /2; }else{ ans = 4 *(x - 1)/2 + 1; } cout<<ans<<endl; }else if(y == x - 2&& x>= 2){ if( x%2 ==0){ ans = ((x - 2)/2) * 4 + 2; }else { ans = (x - 3)/2 * 4 + 3; } cout<<ans<<endl; }else { cout<<"No Number"<<endl; } } return 0;}
- Problem F
- ProBlem F
- Problem F
- Problem F
- Problem F
- Problem F
- problem F
- Problem f
- Problem F
- Problem F
- Problem F
- Problem F
- Problem-F
- Problem F
- Problem F
- Problem-F
- Problem F
- Problem F
- Visual Studio 2010——C#的Splitter和Panel控件的使用
- 手机上网流量谁来监管?
- ASP.NET 后台登录小技巧介绍
- 从一道题谈C++中构造函数调用构造函数
- 自己如何正确获取MYSQL的ADO连接字符串
- Problem F
- Oracle中把一张表查询结果插入到另一张表中
- Android模块编译:m/mm/mmm命令
- 使用log4qt在qt项目中记录日志
- maven项目不显示Maven Dependencies问题
- android摄像头(camera)之 v4l2的c测试代码
- maven+eclipse操作
- 海量数据处理方法总结[转载]
- KMP (看毛片算法) 养成篇 (一)(启发篇)