HDU - 2802 F(N) (周期)
题目链接:HDU 2009-4 Programming Contest
分析:具有一定的周期性——4018处理下就可以A了
Sample Input Sample Output
AC代码:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stdlib.h> using namespace std; #define N 5000
#define INF 0x3f3f3f3f
#define Maxn 100010 int f[N]; int main()
{
int i,n; f[]=;
f[]=;
for(i=; i<=N; i++)
f[i]=(f[i-]+*i*i-*i+)%; while(scanf("%d", &n), n)
{
if(n>=)
n=n%; printf("%d\n", f[n]);
}
return ;
}
HDU - 2802 F(N) (周期)的更多相关文章
- HDU 2802 F(N)(简单题,找循环解)
题目链接 F(N) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
- HDU 2802 F(N) 数论+打表
题目大意: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- ...
- 数学--数论--HDU 2802 F(N) 公式推导或矩阵快速幂
Giving the N, can you tell me the answer of F(N)? Input Each test case contains a single integer N(1 ...
- 【数位DP】 HDU 4734 F(x)
原题直通车:HDU 4734 F(x) 题意:F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2 * 2 + A1 * 1, 求0.....B中F[x]<=F[A ...
- HDU 1005 F(Contest #1)
题意: 已知f[1] = f[2] = 1,输入三个数a,b,n,求f[n] = (a*f[n-1]+b*f[n-2])%7的结果 分析: f[n-1]和f[n-2]最多为7种情况(0,1,2,3,4 ...
- HDU 4734 F(x) 2013 ACM/ICPC 成都网络赛
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4734 数位DP. 用dp[i][j][k] 表示第i位用j时f(x)=k的时候的个数,然后需要预处理下小 ...
- HDU 4734 - F(x) - [数位DP][memset优化]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4734 Time Limit: 1000/500 MS (Java/Others) Memory Lim ...
- HDU 1937 F - Finding Seats 枚举
F - Finding Seats Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- hdu 4734 F(x)(数位dp+优化)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4734 题意:我们定义十进制数x的权值为f(x) = a(n)*2^(n-1)+a(n-1)*2(n-2 ...
随机推荐
- java.util.Iterator
public interface Iterator<E>: 对 collection 进行迭代的迭代器. 方法摘要: boolean hasNext() 如果仍有元素可以迭代,则返回 tr ...
- 10. Regular Expression Matching
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...
- SQL Server 2012中快速插入批量数据的示例及疑惑
SQL Server 2008中SQL应用系列--目录索引 今天在做一个案例演示时,在SQL Server 2012中使用Insert语句插入1万条数据,结果遇到了一个奇怪的现象,现将过程分享出来,以 ...
- wpf之ListBox中ListBoxItem横向排列
ListBox中ListBoxItem默认是纵向排列,可以通过自定义样式,让其横向排列, 如下Demo: XAML: <Window x:Class="ListBoxItemStyle ...
- android 获取系统硬件信息
一,首先设置权限访问: <uses-permission android:name="android.permission.READ_PHONE_STATE" /> ...
- Chapter 1 First Sight——32
The class seemed to drag on longer than the others. 这堂课看起来比别的课要长. Was it because the day was finally ...
- mysql 表连接
1.子查询是指在另一个查询语句中的SELECT子句. 例句: SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2); 其中,SELECT ...
- ACboy needs your help again!
ACboy needs your help again! Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Ja ...
- 如何在spring中获取request对象
1.通过注解获取(很简单,推荐): public class Hello {@Autowired HttpServletRequest request; //这里可以获取到request} 2.在w ...
- 在linux中创建samba,为Windows共享文件
#首先在linux系统安装samba服务 yum install samba 共享一个目录,使用用户名和密码登录后才可以访问,要求可以读写打开samba的配置文件/etc/samba/smb.con ...