标签库元素:

队列<queue> FIFO

栈 <stack>  FICO

集合 set

不定长数组  vector

映射 map

Maximum Multiple

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3985    Accepted Submission(s): 926

Problem Description
Given an integer n, Chiaki would like to find three positive integers x, y and z such that: n=x+y+z, x∣n, y∣n, z∣n and xyz is maximum.
 
Input
There are multiple test cases. The first line of input contains an integer T (1≤T≤106), indicating the number of test cases. For each test case:
The first line contains an integer n (1≤n≤106).
 
Output
For each test case, output an integer denoting the maximum xyz. If there no such integers, output −1 instead.
 
Sample Input
3
1
2
3
 
Sample Output
-1 -1 1
 #include<iostream>
#include<vector>
#include<stdio.h>
using namespace std; int main()
{
long long n;
int t ;
cin>>t;
while(t--)
{
scanf("%lld",&n);
if(n% == ) cout<<(n/)*(n/)*(n/)<<endl;
else
{
if(n% == ) cout<<(n/)*(n/)*(n/)<<endl;
else cout<<-<<endl;
} }
return ;
}

Triangle Partition

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)
Total Submission(s): 2140    Accepted Submission(s): 925
Special Judge

Problem Description
Chiaki has 3n points p1,p2,…,p3n. It is guaranteed that no three points are collinear.
Chiaki would like to construct n disjoint triangles where each vertex comes from the 3n points.
 
Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains an integer n (1≤n≤1000) -- the number of triangle to construct.
Each of the next 3n lines contains two integers xi and yi (−109≤xi,yi≤109).
It is guaranteed that the sum of all n does not exceed 10000.
 
Output
For each test case, output n lines contain three integers ai,bi,ci (1≤ai,bi,ci≤3n) each denoting the indices of points the i-th triangle use. If there are multiple solutions, you can output any of them.
 
Sample Input
1
1
1 2
2 3
3 5
 
Sample Output
1 2 3
 #include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;
struct P
{
long long x,y;
int id;
}p[+];
int cmp(P a,P b)
{
return a.x<b.x;
} int main()
{ int t;
cin>>t;
while(t--)
{
int n ;
cin>>n;
for(int i = ;i <= *n;i++)
{
scanf("%lld %lld",&p[i].x,&p[i].y);
p[i].id = i;
}
sort(p+,p+*n+,cmp); for(int i = ;i<=*n;i++)
{ cout<<p[i].id;
if(i% == ) cout<<endl;
else cout<<" ";
}
}
return ;
}

Time Zone

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5204    Accepted Submission(s): 878

Problem Description
Chiaki often participates in international competitive programming contests. The time zone becomes a big problem.
Given a time in Beijing time (UTC +8), Chiaki would like to know the time in another time zone s.
 
Input
There are multiple test cases. The first line of input contains an integer T (1≤T≤106), indicating the number of test cases. For each test case:
The first line contains two integers a, b (0≤a≤23,0≤b≤59) and a string s in the format of "UTC+X'', "UTC-X'', "UTC+X.Y'', or "UTC-X.Y'' (0≤X,X.Y≤14,0≤Y≤9).
 
Output
For each test, output the time in the format of hh:mm (24-hour clock).
 
Sample Input
3
11 11 UTC+8
11 12 UTC+9
11 23 UTC+0
 
Sample Output
11:11
12:12
03:23
 #include <bits/stdc++.h>
#include <vector>
#include <queue> using namespace std; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b;
char f;
double k;
int q=;
scanf("%d %d UTC%c%lf",&a,&b,&f,&k);
k=k*;
int m1=((int)k%)*;
int h1=(int)k/;
a=(a-+)%; if(f=='+')
{
if(b+m1>=)
{
q=;
}
else q=;
m1=(b+m1)%;
h1=(a+q+h1)%;
}
else if(f=='-')
{
if(m1>b)
{
q=;
}
else q=; m1=(b+-m1)%; h1=(a-q-h1+)%; }
if(h1<=)
{
printf("0%d:",h1);
}
else printf("%d:",h1); if(m1<=)
{
printf("0%d\n",m1);
}
else printf("%d\n",m1); } return ;
}

最新文章

  1. test imetro
  2. 使用对话框 &mdash;&mdash; Dialog
  3. 浅谈 sql 中数据的约束
  4. 127 2016 int
  5. 【T-SQL系列】临时表、表变量
  6. Android基础总结(1)
  7. [SCOI2009]游戏
  8. input text的outline属性
  9. bootstrap 模态框动态加载数据
  10. Android 纵向跑马灯滚动效果
  11. java-多线程(上)
  12. js条件语句初步练习
  13. TStringList 复制 赋值。
  14. C# SpinWait 实现
  15. aptana studio 使用技巧整理
  16. 查看CPU核数和内存
  17. 使用Apache CXF和Spring集成创建Web Service(zz)
  18. Html table 细边框
  19. 64位操作系统下调用32位com的问题
  20. 基于Java 生产者消费者模式(详细分析)

热门文章

  1. ethereum(以太坊)(实例)--&quot;安全的远程购买&quot;
  2. python反射怎么用
  3. notpad++ 搭配 gcc
  4. C# 使用cmd
  5. HyperLedger Fabric 1.4 单机单节点部署(10.2)
  6. CDH集群搭建视频教程 百度云网盘下载
  7. COGS 2199. [HZOI 2016] 活动投票
  8. LWM2M简介-学习记录
  9. Servlet处理文件下载的编码问题,乱码。
  10. imageNamed和imageWithContextOfFile的区别?哪个性能高