UVA305 - Joseph(数论 + 打表)】的更多相关文章

UVA305 - Joseph(数论 + 打表) 题目链接 题目大意:约瑟夫环问题:n个人围成一圈,每次都淘汰第m个人,问最后一个幸存下来的人的编号. 这题的意思有点不一样,它规定前面的k个人是好人,后面的k个人是坏人(2 ∗ k形成环).问最小的m是多少,可以先把后面的k个坏人淘汰再淘汰好人. 解题思路:这题有个递推式:ai = (ai - 1 + m - 1) % (2 ∗ k - (i - 1)) ai表示第i次淘汰的人的编号.后面取余的是剩下的人数. 注意这题的k仅仅可能有14种,可是測…
寻找素数对 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8771    Accepted Submission(s): 4395 Problem Description 哥德巴赫猜想大家都知道一点吧.我们如今不是想证明这个结论,而是想在程序语言内部可以表示的数集中,随意取出一个偶数,来寻找两个素数,使得其和等于该偶数. 做好了这件实…
题目大意:f[n]-n^3=f[n-2]-(n-1)^3 (n >=3),f[1]=1,f[2]=7,求f[n]. 题目思路:将n^3移到到等式右边化简的到:f[n]=f[n-2]+3n*(n-1)+1: 因为第n项与第n-2项有关,所以知道了f[1]与f[2]的值可以分奇偶打下表,找到循环节为4018. #include<cstdio> #include<stdio.h> #include<cstdlib> #include<cmath> #incl…
题意: 对于某数k,若数字d在1-k中出现次数恰好为k,则称k为好数. 给定d,x,求x以内,对于d而言最大的好数.k范围1e18. 题解: 打表二分即可. 但是,1e18的表是没法打出来的,只能在oeis.org上查出来 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<string> #include<stack> #inc…
Joseph Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 44650   Accepted: 16837 Description The Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, . . ., n,…
Joseph Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 493  Solved: 311 Description The Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, . . ., n, standing in circle e…
http://poj.org/problem?id=1012 早上去图书馆复习苦逼的复习....万恶的数逻.T T我还要自我安慰的说复习完了奖励回来刷水题~ 10点多的时候外面校运会大吼撑杆跳的那个.等到解说说要破纪录了,哥哥我果断收拾东西,跑去看,结果即将到的时候说跳过去了记录破了T T哭瞎了. ---------------------------------------------------大家好,我是分割线----------------------------------------…
Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a girlfriend named DouBiNan.One day they felt very boring and decided to play some games. The rule of this game is as following. There are k balls on th…
 Joseph  The Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, ..., n, standing in circle every mth is going to be executed and only the life of the last remaining per…
题目链接:http://acm.swust.edu.cn/problem/1125/ Time limit(ms): 1000 Memory limit(kb): 65535   Description 哈特13最近在学习数论问题,然后他智商太低,并学不懂.这不,他又碰到不会的题了.题意非常简单: 有n个数字,求出这些数字中两两最大公约数的最大值.你一定要帮助他解决这个问题啊. Input 多组输入,约25组,直到文件末尾.每组数据占2行,第一行为数字个数n,2<=n<=100000第二行即为…