USACO 3.2 Factorials】的更多相关文章

Factorials The factorial of an integer N, written N!, is the product of all the integers from 1 through N inclusive. The factorial quickly becomes very large: 13! is too large to store in a 32-bit integer on most computers, and 70! is too large for m…
题意:输出n的阶层最后一个非0数. 题解:可以把5和2的个数算出来,每次把5和2都除掉,最后乘上比5多出来的2.我的解法是,每次把尾巴的0去掉,并且保留3位,算到最后取尾数就可以了.. /* TASK:fact4 LANG:C++ */ #include<cstdio> #include<algorithm> #include<cstring> #define INF 0x3f3f3f3f using namespace std; int main(){ freopen…
这题注意要保存%10000的数. /* ID: yingzho1 LANG: C++ TASK: fact4 */ #include <iostream> #include <fstream> #include <string> #include <map> #include <vector> #include <set> #include <algorithm> #include <stdio.h> #inc…
Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, however…
题意:给你n种价值不同的邮票,最大的不超过10000元,一次最多贴k张,求1到多少都能被表示出来?n≤50,k≤200. 题解:dp[i]表示i元最少可以用几张邮票表示,那么对于价值a的邮票,可以推出dp[j]=min(dp[j],dp[j-a]+1).j从a到k*10000顺序枚举,因为类似于完全背包. http://train.usaco.org/usacoprob2?a=fSgPyIazooa&S=stamps /* TASK:stamps LANG:C++ */ #include<c…
题目背景 N的阶乘写作N!,表示小于等于N的所有正整数的乘积. 题目描述 阶乘会变大得很快,如13!就必须用32位整数类型来存储,到了70!即使用浮点数也存不下了. 你的任务是找到阶乘最前面的非零位.举个例子: 5!=1*2*3*4*5=120,所以5!的最靠前的非零位是1. 7!=1*2*3*4*5*6*7=5040,所以最靠前的非零位是5. 输入输出格式 输入格式: 共一行,一个不大于4,220的正整数N 输出格式: 共一行,输出N!最靠后的非零位. 输入输出样例 输入样例#1: 7 输出样…
USACO 2013 NOV SILVER 一.题目概览 中文题目名称 未有的奶牛 拥挤的奶牛 弹簧牛 英文题目名称 nocow crowded pogocow 可执行文件名 nocow crowded pogocow 输入文件名 nocow.in crowded.in pogocow.in 输出文件名 nocow.out crowded.out pogocow.out 每个测试点时限 1秒 1秒 1秒 测试点数目 10 10 10 每个测试点分值 10 10 10 比较方式 全文比较 全文比较…
USACO 2013 DEC SILVER 一.题目概览 中文题目名称 挤奶调度 农场航线 贝西洗牌 英文题目名称 msched vacation shuffle 可执行文件名 msched vacation shuffle 输入文件名 msched.in vacation.in shuffle.in 输出文件名 msched.out vacation.out shuffle.out 每个测试点时限 1秒 1秒 1秒 测试点数目 10 10 10 每个测试点分值 10 10 10 比较方式 全文…
USACO 2014 DEC SILVER 一.题目概览 中文题目名称 回程 马拉松 奶牛慢跑 英文题目名称 piggyback marathon cowjog 可执行文件名 piggyback marathon cowjog 输入文件名 piggyback.in marathon.in cowjog.in 输出文件名 piggyback.out marathon.out cowjog.out 每个测试点时限 1秒 1秒 1秒 测试点数目 10 10 10 每个测试点分值 10 10 10 比较…
USACO 2012 FEB SILVER 一.题目概览 中文题目名称 矩形草地 奶牛IDs 搬家 英文题目名称 planting cowids relocate 可执行文件名 planting cowids relocate 输入文件名 planting.in cowids.in relocate.in 输出文件名 planting.out cowids.out relocate.out 每个测试点时限 1秒 1秒 1秒 测试点数目 10 10 10 每个测试点分值 10 10 10 比较方式…