Floor Function


Time Limit: 10 Seconds      Memory Limit: 65536 KB

abc and d are all positive integers which satisfy bc - ad > 0. Your task is to minimize the following function of a positive integer n.

x⌋, the floor function, means the largest integer not greater than x.

You need to find a positive integer n to minimize the above function. If there are multiple n's minimizing it, find the smallest one.

Input

There are multiple test cases. The first line of input contains an integer T ≈ 100000 indicating the number of test cases. For each test case:

There are four positive integers: abc and d. (1 <= a, b, c, d <= 1018)

Output

For each case, print the smallest positive integer n which minimizes the function.

Sample Input

3
1 2 3 4
3 4 4 5
97 37 101 31

Sample Output

2
4
1 题意:求最小的n使得等式结果最小
待更新....
转载请注明出处:寻找&星空の孩子

Permutation Graph


Time Limit: 3 Seconds      Memory Limit: 65536 KB

Edward has a permutation {a1a2, … an}. He finds that if he connects each pair (aiaj) such that i < j and ai > aj, he will get a graph.

For example, if the permutation is {2, 3, 1, 4}, then 1 and 2 are connected and 1 and 3 are connected.

Edward lost his permutation, but he does know the connected components of the corresponding graph. He wants to know how many permutations will result in the same connected components.

Note that two vertices uv belong to the same connected component if there exists a sequence of vertices starting with u and ending with v such that every two subsequent vertices in the sequence are connected by an edge.

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 two integers nm (1 ≤ m ≤ n ≤ 100000), indicating the length of the permutation and the number of connected components in the graph.

Each of the following m lines contains an integer ci which denotes the size of i-th connected component, followed by ci distinct integers vi,1vi,2, … vi,ci which denotes the connected component (1 ≤ civi,1vi,2, … vi,ci≤ n).

It is guaranteed that every number will appear in exact one connected component and c1 + c2 + … + cm = n.

Output

For each case, output the answer modulo 786433.

Sample Input

2
4 4
1 1
1 2
1 3
1 4
4 2
3 1 2 3
1 4

Sample Output

1
3

Hint

For the second case, the three permutations is: {2, 3, 1, 4}, {3, 2, 1, 4}, {3, 1, 2, 4}.


题意:每个集合里,每个大数可以把后面的小数连起来,问你全部能连起来的组合个数;
待更新...
转载请注明出处:寻找&星空の孩子

Lunch Time


Time Limit: 2 Seconds      Memory Limit: 65536 KB

The 999th Zhejiang Provincial Collegiate Programming Contest will be held in Marjar University. The canteen of Marjar University is making preparations for this grand competition. The canteen provides a lunch set of three types: appetizer, main course and dessert. Each type has several dishes with different prices for choosing.

Edward is the headmaster of Marjar University. One day, to inspect the quality of dishes, he go to the canteen and decides to choose a median set for his lunch. That means he must choose one dish from each of appetizers, main courses and desserts. Each chosen dish should at the median price among all dishes of the same type.

For example, if there are five dessert dishes selling at the price of 2, 3, 5, 10, 30, Edward should choose the dish with price 5 as his dessert since its price is located at the median place of the dessert type. If the number of dishes of a type is even, Edward will choose the dish which is more expensive among the two medians.

You are given the list of all dishes, please write a program to help Edward decide which dishes he should choose.

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 three integers SM and D (1 <= SMD <= 100), which means that there are S dishes of appetizer, M dishes of main course and D dishes of dessert.

Then followed by three parts. The first part contains S lines, the second and the last part contains M and D lines respectively. In each line of the three parts, there is a string and an integer indicating the name and the price of a dish. The name of dishes will only consist of non-whitespace characters with no more than 50 characters. The price of dishes are non-negative integers less than or equal to 1000. All dish names will be distinct.

Output

For each test case, output the total price of the median set, together with the names of appetizer, main course and dessert, separated by a single space.

Sample Input

2
1 3 2
Fresh_Cucumber 4
Chow_Mein 5
Rice_Served_with_Duck_Leg 12
Fried_Vermicelli 7
Steamed_Dumpling 3
Steamed_Stuffed_Bun 4
2 3 1
Stir-fried_Loofah_with_Dried_Bamboo_Shoot 33
West_Lake_Water_Shield_Soup 36
DongPo's_Braised_Pork 54
West_Lake_Fish_in_Vinegar 48
Longjing_Shrimp 188
DongPo's_Crisp 18

Sample Output

15 Fresh_Cucumber Fried_Vermicelli Steamed_Stuffed_Bun
108 West_Lake_Water_Shield_Soup DongPo's_Braised_Pork DongPo's_Crisp
题意:求每组甜点的中位数的和,如果有中位数有2组,取价格大的;
转载请注明出处:寻找&星空の孩子
 
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
#define ls 2*i
#define rs 2*i+1
#define up(i,x,y) for(i=x;i<=y;i++)
#define down(i,x,y) for(i=x;i>=y;i--)
#define mem(a,x) memset(a,x,sizeof(a))
#define w(a) while(a)
#define LL long long
const double pi = acos(-1.0);
#define Len 20005
#define mod 19999997
const int INF = 0x3f3f3f3f; int t,a,b,c; struct node
{
char name[];
int num;
}s[][]; int cmp(node a,node b)
{
return a.num<b.num;
} int main()
{
int i,j,k;
scanf("%d",&t);
w(t--)
{
scanf("%d%d%d",&a,&b,&c);
up(i,,a-)
scanf("%s%d",s[][i].name,&s[][i].num);
up(i,,b-)
scanf("%s%d",s[][i].name,&s[][i].num);
up(i,,c-)
scanf("%s%d",s[][i].name,&s[][i].num);
sort(s[],s[]+a,cmp);
sort(s[],s[]+b,cmp);
sort(s[],s[]+c,cmp);
int ans=s[][a/].num+s[][b/].num+s[][c/].num;
printf("%d %s %s %s\n",ans,s[][a/].name,s[][b/].name,s[][c/].name);
} return ;
}

May Day Holiday


Time Limit: 2 Seconds      Memory Limit: 65536 KB

As a university advocating self-learning and work-rest balance, Marjar University has so many days of rest, including holidays and weekends. Each weekend, which consists of Saturday and Sunday, is a rest time in the Marjar University.

The May Day, also known as International Workers' Day or International Labour Day, falls on May 1st. In Marjar University, the May Day holiday is a five-day vacation from May 1st to May 5th. Due to Saturday or Sunday may be adjacent to the May Day holiday, the continuous vacation may be as long as nine days in reality. For example, the May Day in 2015 is Friday so the continuous vacation is only 5 days (May 1st to May 5th). And the May Day in 2016 is Sunday so the continuous vacation is 6 days (April 30th to May 5th). In 2017, the May Day is Monday so the vacation is 9 days (April 29th to May 7th). How excited!

Edward, the headmaster of Marjar University, is very curious how long is the continuous vacation containing May Day in different years. Can you help him?

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, there is an integer y (1928 <= y <= 9999) in one line, indicating the year of Edward's query.

Output

For each case, print the number of days of the continuous vacation in that year.

Sample Input

3
2015
2016
2017

Output

5
6
9

题意:问五一放几天假,首先确定每年的五一在哪一天,因为周日到周六,都可以打表表示,所以确定闰年的个数就可以了,是闰年对应的星期就+2,其余的+1(相对与1928年)

转载请注明出处:寻找&星空の孩子
//1928年周二
#include<stdio.h>
int a[]= {,,,,,,};
int main()
{
int year,T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&year);
int k=year-;
int cnt=;
for(int i=; i<=year; i++)
{
if(i%==||(i%==&&i%!=)) cnt++;
}
printf("%d\n",a[(+k+cnt)%]);
}
return ;
}

140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)的更多相关文章

  1. 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(浙江省赛2015)

      Ace of Aces Time Limit: 2 Seconds      Memory Limit: 65536 KB There is a mysterious organization c ...

  2. 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第三部分)

    Earthstone Keeper Time Limit: 4 Seconds      Memory Limit: 65536 KB Earthstone Keeper is a famous ro ...

  3. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...

  4. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  5. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...

  6. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

  7. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502  The 12th Zhejiang Provincial ...

  8. zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...

  9. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504  The 12th Zhejiang Provincial ...

随机推荐

  1. 如何使用Visual Studio 2017调试.net库源代码

    在Visual Studio 2017按如下步骤设置: 1.取消选中(工具 - >选项 - >调试 - >仅我的代码)复选框.2.确保设置了(工具 - >选项 - >调试 ...

  2. Elastic-search在linux上的安装

    今天是我装第四次 ES ,之前装好用了一段时间,后面莫名其妙爆炸了,炸出一堆异常... 安装环境: JDK1.8   centos    ElasticSearch-6.2.4 jdk1.8以上,所以 ...

  3. 音视频编解码——YUV视频格式详解

    一.YUV 介绍 YUV是一种颜色编码方方式,通常由彩色摄像机进行取像,然后把取得的彩色图像信号经过分色.分别放大校正后得到RGB,再经过矩阵变换得到亮度信号Y和两个色差信号B-Y(即U).R-Y(即 ...

  4. opus在arm的嵌入式平台上的移植和开发

    最近产品中要用到opus,圣上一声令下,把opus移植到我们平台上,什么?opus?opus是什么?在一脸 茫然中,我这特种兵码农就赤手空拳上战场了. 废话少说,赶紧在网站:https://opus- ...

  5. jsp和servlet的关系

    JSP是Servlet技术的扩展,本质上就是Servlet的简易方式.JSP编译后是“类servlet”. Servlet和JSP最主要的不同点在于:Servlet的应用逻辑是在Java文件中,并且完 ...

  6. Java开发技术大揭底——让你认知自己技术上的缺陷,成为架构师

    一.分布式架构体系 分布式怎么来的.传统的电信.银行业,当业务量大了之后,普通服务器CPU/IO/网络到了100%,请求太慢怎么办?最直接的做法,升级硬件,反正也不缺钱,IBM小型机,大型机,采购了堆 ...

  7. 用eclipse导入打war包的maven项目

    最近遇到Maven管理下的Spring MVC项目,组内某位将项目代码扔过来,一脸懵逼(囧),查阅了一些资料后终于将此项目运行通了(>_<),特此记录下来与各位分享. 通俗的来说,Mave ...

  8. Python:渗透测试开源项目【源码值得精读】

    sql注入工具:sqlmap DNS安全监测:DNSRecon 暴力破解测试工具:patator XSS漏洞利用工具:XSSer Web服务器压力测试工具:HULK SSL安全扫描器:SSLyze 网 ...

  9. oracle新建用户并授权步凑

    #首先创建表空间.存放路径.设置表空间大小 create tablespace tbs_ams datafile '+DATA/pdorcl1/datafile/ams1.dbf' size 1024 ...

  10. Intellij新安装初始化配置

    自动编译开关 忽略大小写开关 IDEA默认是匹配大小写,此开关如果未关.你输入字符一定要符合大小写.比如你敲string是不会出现代码提示或智能补充.但是,如果你开了这个开关,你无论输入String或 ...