【Codeforces Round #447 (Div. 2) B】Ralph And His Magic Field
and Codeforces div round Field Magic
2023-09-14 09:03:45 时间
| 【链接】 我是链接,点我呀:)
【题意】
【题解】
显然每个位置只能填1或-1 如果只考虑前n-1行和前m-1列。 那么我们对这(n-1)*(m-1)的范围。 先任意填入数字; 则一共有$2^{(n-1)*(m-1)}$种方法。 然后把最后一行的前m-1列填一下。 使得前m-1列满足,每一列的乘积为k 然后把最后一列的前n-1行填一下使前n-1行每一行的乘积都为k 最后填最右下角那个格子。 会发现,行数和列数如果奇偶不同的话,且k=-1的话,那个格子是没办法满足每行每列的要求的 除了这种情况之外,都能满足要求,即填一个唯一的数字,使得最后一行,最后一列的乘积都为k (根据整个矩形的-1的个数的奇偶性来判断)【代码】
/*
1.Shoud it use long long ?
2.Have you ever test several sample(at least therr) yourself?
3.Can you promise that the solution is right? At least,the main ideal
4.use the puts("") or putchar() or printf and such things?
5.init the used array or any value?
6.use error MAX_VALUE?
7.use scanf instead of cin/cout?
*/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
LL n,m;
int k;
const LL MOD = 1e9 + 7; // ģ��
LL Pow(LL x,LL y){ //��x^y
LL a = 1;x%=MOD;
while (y){
if (y&1) a = (a*x)%MOD;
x=(x*x)%MOD;
y>>=1;
}
return a;
}
int main(){
#ifdef LOCAL_DEFINE
freopen("F:\\c++source\\rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
cin >> n >> m >> k;
if (k==-1 && ((n&1)!=(m&1))){
cout << 0 << endl;
}else{
cout << Pow(Pow(2,n-1),m-1) << endl;
}
return 0;
}
相关文章
- Academic social networks: Modeling, analysis, mining and applications 2019翻译
- 文献阅读:Image as a Foreign Language: BEIT Pretraining for All Vision and Vision-Language Tasks
- Blazor Server完美实现Cookie Authorization and Authentication
- ORA-01235: END BACKUP failed for string file(s) and succeeded for string ORACLE 报错 故障修复 远程处理
- ORA-32600: RETENTION and PCTVERSION cannot be used together ORACLE 报错 故障修复 远程处理
- MySQL Error number: 1884; Symbol: ER_GTID_UNSAFE_BINLOG_SPLITTABLE_STATEMENT_AND_GTID_GROUP; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-48104: read mismatch on blocks requested and returned, [string], [string] ORACLE 报错 故障修复 远程处理
- ORA-06808: TLI Driver: could not link IPX and ethernet streams ORACLE 报错 故障修复 远程处理
- ORA-13633: The task string was interrupted and needs to be resumed. ORACLE 报错 故障修复 远程处理
- Oracle between and 边界问题详解数据库
- Codeforces 842B Gleb And Pizza几何,水详解编程语言
- Apache PHP and MySQL: A Match Made in Heaven(apachephpmysql)
- MySQL中的OR与AND操作符比较(mysqlor和and)
- 多条件查询MySQL中使用And多条件查询的步骤(mysql中and)
- MySQL and PHP: Establishing the Perfect Connection(mysql链接php)
- 条件MySQL 子句之间`AND`操作符多条件查询(mysql多个and)
- Exploring the Features and Benefits of Zebra Linux for Modern Computing Needs(zebralinux)
- Exploring the Power of Linux Stat and Understanding Its Impact on File Management(linuxstatm)
- Mastering MySQL: The Ultimate Guide to Table Definition and Design(mysql表定义)
- Guide to Initializing an Oracle Database: Tips and Tricks(oracle初始化数据库)
- MySQL中AND的使用方法解析(mysql中and的用法)
- MySQL中的AND逻辑操作符是什么(mysql中and是什么)
- MySQL中的AND和OR使用逻辑运算符优化查询语句(mysql中and与or)
- and的区别Oracle数据库中的OR与AND的差异(oracle中or和)
- Oracle 数据库中使用AND拼接的威力(oracle中and拼接)