C++学习
文章平均质量分 66
以前和现在的C++
TRS_07170
既是程序猿也是二次猿
展开
-
2021-01-09 USACO Hamming Codes
Given N, B, and D: Find a set of N codewords (1 <= N <= 64), each of length B bits (1 <= B <= 8), such that each of the codewords is at least Hamming distance of D (1 <= D <= 7) away from each of the other codewords.The Hamming distance原创 2021-01-09 16:06:57 · 101 阅读 · 0 评论 -
2021-01-09 USACO Healthy Holsteins
Farmer John prides himself on having the healthiest dairy cows in the world. He knows the vitamin content for one scoop of each feed type and the minimum daily vitamin requirement for his cows. Help Farmer John feed the cows so they stay healthy while mini原创 2021-01-09 12:14:19 · 143 阅读 · 0 评论 -
2021-01-07 USACO Sorting a Three-Valued Sequence
Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at mostthreedifferent key values. This happens for instance when we sort medalists of a competition according..原创 2021-01-07 17:39:40 · 95 阅读 · 0 评论 -
2021-01-07 USACO Ordered Fractions
Consider the set of all reduced fractions between 0 and 1 inclusive with denominators less than or equal to N.Here is the set when N = 5:0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1Write a program that, given an integer N between 1 and 160 inclusive原创 2021-01-07 16:15:30 · 155 阅读 · 1 评论 -
2021-01-07 USACO The Castle
In a stroke of luck almost beyond imagination, Farmer John was sent a ticket to the Irish Sweepstakes (really a lottery) for his birthday. This ticket turned out to have only the winning number for the lottery! Farmer John won a fabulous castle in the Iris原创 2021-01-07 15:06:20 · 88 阅读 · 0 评论 -
2021-01-06 USACO Superprime Rib
Butchering Farmer John's cows always yields the best prime rib. You can tell prime ribs by looking at the digits lovingly stamped across them, one by one, by FJ and the USDA. Farmer John ensures that a purchaser of his prime ribs gets really prime ribs bec原创 2021-01-06 17:49:20 · 123 阅读 · 0 评论 -
2021-01-06 USACO Prime Palindromes
The number 151 is a prime palindrome because it is both a prime number and a palindrome (it is the same number when read forward as backward). Write a program that finds all prime palindromes in the range of two supplied numbers a and b (5 <= a < b &原创 2021-01-06 15:55:13 · 76 阅读 · 0 评论 -
2021-01-06 USACO Number Triangles
Consider the number triangle shown below. Write a program that calculates the highest sum of numbers that can be passed on a route that starts at the top and ends somewhere on the base. Each step can go either diagonally down to the left or diagonally down原创 2021-01-06 12:19:20 · 115 阅读 · 0 评论 -
2021-01-05 USACO Mother‘s Milk
Farmer John has three milking buckets of capacity A, B, and C liters. Each of the numbers A, B, and C is an integer from 1 through 20, inclusive. Initially, buckets A and B are empty while bucket C is full of milk. Sometimes, FJ pours milk from one bucket原创 2021-01-05 20:46:00 · 157 阅读 · 0 评论 -
2021-01-05 USACO Arithmetic Progressions
An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb where n=0, 1, 2, 3, ... . For this problem, a is a non-negative integer and b is a positive integer.Write a program that finds all arithmetic progressions of length n in the set原创 2021-01-05 17:16:29 · 127 阅读 · 0 评论 -
2021-01-05 USACO Ski Course Design
Farmer John has N hills on his farm (1 <= N <= 1,000), each with an integer elevation in the range 0 .. 100. In the winter, since there is abundant snow on these hills, FJ routinely operates a ski training camp.Unfortunately, FJ has just found out原创 2021-01-05 11:39:54 · 132 阅读 · 0 评论 -
2021-01-04 USACO Wormholes
Farmer John's hobby of conducting high-energy physics experiments on weekends has backfired, causing N wormholes (2 <= N <= 12, N even) to materialize on his farm, each located at a distinct point on the 2D map of his farm (the x,y coordinates are bo原创 2021-01-04 11:58:15 · 122 阅读 · 0 评论 -
2021-01-02 USACO Combination Lock
Farmer John's cows keep escaping from his farm and causing mischief. To try and prevent them from leaving, he purchases a fancy combination lock to keep his cows from opening the pasture gate.Knowing that his cows are quite clever, Farmer John wants to m原创 2021-01-02 17:04:51 · 85 阅读 · 0 评论 -
2021-01-02 USACO Prime Cryptarithm
(This poorly named task has nothing to do with prime numbers or even, really, prime digits. Sorry 'bout that.)A cryptarithm is usually presented as a pencil-and-paper task in which the solver is required to substitute a digit for each of the asterisks (o原创 2021-01-02 15:39:08 · 121 阅读 · 0 评论 -
2021-01-02 USACO Barn Repair
It was a dark and stormy night that ripped the roof and gates off the stalls that hold Farmer John's cows. Happily, many of the cows were on vacation, so the barn was not completely full.The cows spend the night in stalls that are arranged adjacent to ea原创 2021-01-02 12:55:10 · 73 阅读 · 0 评论 -
2021-01-01 USACO Mixing Milk
The Merry Milk Makers company buys milk from farmers, packages it into attractive 1- and 2-Unit bottles, and then sells that milk to grocery stores so we can each start our day with delicious cereal and milk.Since milk packaging is such a difficult busin原创 2021-01-01 23:33:01 · 195 阅读 · 0 评论 -
2021-01-01 USACO Dual Palindromes
A number that reads the same from right to left as when read from left to right is called a palindrome. The number 12321 is a palindrome; the number 77778 is not. Of course, palindromes have neither leading nor trailing zeroes, so 0220 is not a palindrome.原创 2021-01-01 20:17:07 · 92 阅读 · 0 评论 -
2021-01-01 USACO Palindromic Squares
Palindromes are numbers that read the same forwards as backwards. The number 12321 is a typical palindrome.Given a number base B (2 <= B <= 20 base 10), print all the integers N (1 <= N <= 300 base 10) such that the square of N is palindromic原创 2021-01-01 19:46:16 · 79 阅读 · 0 评论 -
2020-12-31 USACO Name That Number
Among the large Wisconsin cattle ranchers, it is customary to brand cows with serial numbers to please the Accounting Department. The cow hands don't appreciate the advantage of this filing system, though, and wish to call the members of their herd by a pl原创 2020-12-31 17:29:01 · 134 阅读 · 0 评论 -
2020-12-31 USACO Transformations
A square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into another square pattern. Write a program that will recognize the minimum transformation that has been applied to the original pattern given the following li原创 2020-12-31 14:38:37 · 103 阅读 · 0 评论 -
2020-12-31 重新学习C++ 之 指针
用指针写的链表从刚开始就没有彻底理解链表的原理,所以一直就是背的板子。直到今天学了指针,拿指针写链表,才觉得很透彻。指针的思路真的比数组清晰很多。#include<cstdio>#include<iostream>#include<cstdlib>using namespace std;struct Node { int value; Node* next;}; struct List { Node* head; Node* last;原创 2020-12-31 11:49:43 · 65 阅读 · 0 评论 -
2020-12-30 USACO Milking Cows
Three farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer begins milking his cow at time 300 (measured in seconds after 5 am) and ends at time 1000. The second farmer begins at time 700 and ends at time 1200. The th原创 2020-12-31 11:46:52 · 70 阅读 · 0 评论 -
2020-12-30 USACO Broken Necklace
You have a necklace of N red, white, or blue beads (3<=N<=350) some of which are red, others blue, and others white, arranged at random. Here are two examples for n=29: 1 2 1 2 r b b r原创 2020-12-31 11:45:25 · 105 阅读 · 0 评论 -
2020-12-30 USACO Friday the Thirteenth
Is Friday the 13th really an unusual event?That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13th of each month lands on Su原创 2020-12-31 11:42:56 · 123 阅读 · 0 评论 -
2020-12-30 USACO Greedy Gift Givers
Task 'gift1': Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to some or all of the other friends (although some might be cheap and giv原创 2020-12-31 11:39:02 · 138 阅读 · 0 评论 -
2020-12-29 USACO Your Ride Is Here
/*ID: traysen1PROG: rideLANG: C++*/#include<iostream>#include<fstream>#include<cstring>using namespace std;const int MOD = 47;char comet[20], group[20];int comet_number = 1, group_number = 1;int main() { ifstream fin ("r...原创 2020-12-31 11:34:04 · 67 阅读 · 0 评论 -
luogu P3694 邦邦的大合唱站队
任重而道远题目背景BanG Dream!里的所有偶像乐队要一起大合唱,不过在排队上出了一些问题。题目描述N个偶像排成一列,他们来自M个不同的乐队。每个团队至少有一个偶像。现在要求重新安排队列,使来自同一乐队的偶像连续的站在一起。重新安排的办法是,让若干偶像出列(剩下的偶像不动),然后让出列的偶像一个个归队到原来的空位,归队的位置任意。请问最少让多少偶像出列?输入输出格式...原创 2018-11-08 17:07:54 · 189 阅读 · 0 评论 -
CodeForces 1073C (二分答案)
任重而道远题目链接:http://codeforces.com/problemset/problem/1073/CAC代码:#pragma optimize GCC ("O2")#include<bits/stdc++.h>using namespace std;const int N = 2e5 + 5;char s[N];int n, p, q, x[N]...原创 2018-11-05 19:01:57 · 313 阅读 · 0 评论 -
luogu P2943 [USACO09MAR]清理Cleaning Up(dp +类似链表预处理)(思维题)
任重而道远题目描述In the good old days, Farmer John served a boring cuisine comprising but a single type of cow food to his N (1 <= N <= 40000) prize dairy cows. Times change. Today he serves the her...原创 2018-11-05 18:54:03 · 234 阅读 · 0 评论 -
2018.11.02校内测试liu_runda的周任飞之任(duty)
任重而道远Solution:在考场上居然没想出来,大失败。。。出题人的疯狂暗示居然没有看出来。。。树啊!!!每一个连通块都是一棵树。。对于树的基本性质你想到了什么??边数等于点数减一,这恰好可以拿来计算连通块的数量(连通块数 = 所求子矩阵中的点数减边数)这样只需要分别对点数和边数维护二维前缀和。其中处理边数的时候有细节应注意:左边界那一竖列代表的还有向...原创 2018-11-02 16:40:35 · 313 阅读 · 0 评论 -
CodeForces 859C Pie Rules(dp逆推)
任重而道远You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets...原创 2018-11-01 20:49:48 · 229 阅读 · 0 评论 -
2018.10.31校内测试
任重而道远Solution:AC代码:#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>using namespace std;typedef long long ll;const int N = 1e5 + 5, Mod =...原创 2018-11-01 16:29:47 · 152 阅读 · 0 评论 -
2018.11.01 neither_nor 的随(rand)
任重而道远AC代码:#include<bits/stdc++.h>using namespace std;const int Mod = 1e9 + 7;int f[1005], tmp[1005], rt[1005];int read () { int x = 0, f = 0; char c = getchar (); while (!isdigi...原创 2018-11-01 16:20:09 · 157 阅读 · 0 评论 -
BZOJ 4326 运输计划(LCA +树上差分)
任重而道远Description公元 2044 年,人类进入了宇宙纪元。L 国有 n 个星球,还有 n?1 条双向航道,每条航道建立在两个星球之间,这 n-1 条航道连通了 L 国的所有星球。小 P 掌管一家物流公司, 该公司有很多个运输计划,每个运输计划形如:有一艘物流飞船需要从 ui 号星球沿最快的宇航路径飞行到 vi 号星球去。显然,飞船驶过一条航道是需要时间的,对于航道...原创 2018-10-30 20:06:52 · 153 阅读 · 0 评论 -
luogu P2425 小红帽的回文数 (进制相关 +思维)
任重而道远题目描述小红帽喜欢回文数,但生活中的数常常不是回文数。现在她手上有t个数,现在她知道这t个数分别在x进制下是回文数(x>=2),请你对于每个数求出最小的x.输入输出格式输入格式:第一行为一个t(1<=t<=1000)接下来的t行,每行为一个数ai(0<=ai<=10^10)。输出格式:输出有t行,每行为所求的x。输入输出样...原创 2018-10-28 21:03:15 · 178 阅读 · 0 评论 -
线段树相关练习
任重而道远AC代码:#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>using namespace std;typedef long long ll;const int N = 1e5 + 5;struct Node { l...原创 2018-10-25 19:54:33 · 154 阅读 · 0 评论 -
BZOJ2144 【国家集训队】跳跳棋(建模 + 二分 + LCA)
任重而道远跳跳棋是在一条数轴上进行的。棋子只能摆在整点上。每个点不能摆超过一个棋子。我们用跳跳棋来做一个简单的游戏:棋盘上有3颗棋子,分别在a,b,c这三个位置。我们要通过最少的跳动把他们的位置移动成x,y,z。(棋子是没有区别的)跳动的规则很简单,任意选一颗棋子,对一颗中轴棋子跳动。跳动后两颗棋子距离不变。一次只允许跳过1颗棋子。写一个程序,首先判断是否可以完成任务。如果...原创 2018-10-25 10:41:01 · 261 阅读 · 0 评论 -
HDU 3401 Trade(DP + 单调队列优化)
任重而道远Recently, lxhgww is addicted to stock, he finds some regular patterns after a few days' study.He forecasts the next T days' stock market. On the i'th day, you can buy one stock with the price ...原创 2018-10-21 10:45:24 · 183 阅读 · 0 评论 -
POJ 1862 Stripies(贪心 + 堆)
任重而道远Our chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian - polosatiki, but the scientists had to invent an English name t...原创 2018-10-20 23:34:03 · 114 阅读 · 0 评论 -
Codeforces 980E The Number Games (贪心 + 倍增)
任重而道远The nation of Panel holds an annual show called The Number Games, where each district in the nation will be represented by one contestant.The nation has nn districts numbered from 11 to nn , ...原创 2018-10-20 23:27:56 · 181 阅读 · 0 评论