计蒜客 方程的解数(DFS)
2024-10-08 19:25:32
问题描述
输出格式
输出一行,输出一个整数,表示方程的整数解的个数。
样例输入
-
样例输出
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
const int INF=0x3f3f3f3f;
typedef long long LL;
const int mod=1e9+;
const double PI = acos(-);
const double eps =1e-;
#define Bug cout<<"---------------------"<<endl
const int maxn=1e5+;
using namespace std; int k[],p[];
int n,m,ans;
LL POW[][];//POW[i][j]表示i的j次方 void init()//打表
{
for(int i=;i<=;i++)
{
POW[i][]=;
for(int j=;j<=;j++)
{
POW[i][j]=i*POW[i][j-];
}
}
} void DFS(int step,LL sum)
{
if(step>n)
{
if(sum==) ans++;
return ;
}
for(int i=;i<=m;i++)
DFS(step+,sum+k[step]*POW[i][p[step]]);
} int main()
{
#ifdef DEBUG
freopen("sample.txt","r",stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); scanf("%d %d",&n,&m);
for(int i=;i<=n;i++)
scanf("%d %d",&k[i],&p[i]);
init();//不要忘了
DFS(,);
printf("%d\n",ans); return ;
}
-
最新文章
- pwnable echo1
- 股票交易(洛谷U6084)
- iOS8定位问题解决方案
- java泛型的使用
- Windows 8上强制Visual Studio以管理员身份运行
- Delphi的Owner与Parent可以不一致,而且Owner不是必须存在(一共7个问题) good
- android strings.xml转义字符, 注意细节解决(转)
- boostrap插件
- response 常用详解(1)
- Spring AOP分析(1) -- 基本概念
- POJ 1849 Two(树的直径--树形DP)(好题)
- Alpha冲刺置顶随笔
- Linux安装mysql(Redhat6.5+MySQL5.7)(转载+原创补漏)
- 翻转 -- CodeForces - 56B
- 【原创】大叔经验分享(36)CM部署kafka
- FZU 2254 英语考试 (最小生成树)
- 洛谷P1605 迷宫【dfs】
- python 回溯法 记录
- 一次性解决Intellij IDEA maven 自动跳到1.5的JDK
- Unity3D Shader基础教程