link:http://codeforces.com/problemset/problem/340/C 开始一点也没思路,赛后看别人写的代码那么短,可是不知道怎么推出来的啊! 后来明白了. 首先考虑第一个数字,就是和0想减的内个.那么剩下的n-1个数字有(n-1)!个排列方式.所以呢,在n!个式子里面,第一个位置的和就是:a1 * (n-1)! + a2 * (n-1)! + ...... + an * (n-1)!: 然后考虑其它位置:对于ai , aj . 并且相邻.那么剩下 n - 2 个…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Tourist Problem Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts…
题意:固定起点是0,给出一个序列表示n个点,所有点都在一条直线上,其中每个元素代表了从起点到这个点所走的距离.已知路过某个点不算到达这个点,则从起点出发,到达所有点的方案有许多种.求所有方案走的总路程/方案数,输出分子.分母,要求不含约数. e.g:n=3 {2,3,5},{2,3,5}{2,5,3}{3,2,5}{3,5,2}{5,2,3}{5,3,2},总路程(5+7+7+8+9+8)=44,答案44/6=22/3,输出“22 3”. 分析: 1.以n=3序列{a1,a2,a3}为例,实际上…
题目链接:https://nanti.jisuanke.com/t/30990 Alice, a student of grade 6, is thinking about an Olympian Math problem, but she feels so despair that she cries. And her classmate, Bob, has no idea about the problem. Thus he wants you to help him. The proble…
先上题目: A - Tourist Problem Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 340C Description Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. The…
拉题链接  https://vjudge.net/contest/430219#overview 原题链接  https://codeforces.com/problemset/problem/340/C 前言 cf 1600的题, 直接拿来给大一的做, 感觉有亿点点难, 这是个纯数学题, 我用的排列组合方法推导 题目 题意(其实我觉得还是看上边的Note好理解) 给n个数(分别为a1, a2 ...... an-1, 把这n个数全排(共Ann 个序列)一遍, 对于每个序列, 值=每个|ai -…
C. Tourist Problem time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a…
C. Tourist Problem time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a…
http://codeforces.com/problemset/problem/340/C 赛时没想出赛后却能较快想出深深的教育自己做题一定要静下心来,不要轻易放弃,认真思考,不要浮躁着急,不要太容易受外界影响 C. Tourist Problem time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub is a big…
题目链接:http://codeforces.com/problemset/problem/1096/D 题意: 给出一个小写字母组成的字符串,如果该字符串的某个子序列为 $hard$,就代表这个字符串是不好的. 现在你要删掉若干字母,使得字符串是好的,同时删除第 $i$ 个字母会使得歧义程度增加 $a[i]$,你需要让歧义程度最低,输出这个值. 题解: $dp[i][x=0,1,2,3]$ 的状态是前 $i$ 个字母,第二维 $x$ 代表:$0$——不包含任何有可能构成 “$hard$” 的子…