题目链接:uva 847 - A Multiplication Game
题目大意:给定n,有p=1,每次操作可以给p乘上2~9,两个人人轮流操作,当p>=n时获胜。
解题思路:算半个贪心吧,2~9为必胜,10~18为必败,19~162为必胜。。。即每次乘9,如果大于则是Stan胜,再乘2,如果大于则是Oliie
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
bool judge (ll n) {
ll p = 1;
while (p < n) {
p *= 9;
if (p >= n)
return true;
p *= 2;
if (p >= n)
return false;
}
return false;
}
int main () {
ll n;
while (scanf("%lld", &n) == 1) {
printf("%s wins.\n", judge(n) ? "Stan" : "Ollie");
}
return 0;
}
分享到:
相关推荐
Source Code for 2009 Supercomputing Paper Implementing Sparse Matrix-Vector Multiplication on Throughput-Oriented Processors
lvds-source-synch-serdes-clock-multiplication.pdf
在三值光学计算机上进行的矢量乘矩阵运算,金翊,王先超,本文报道一种进行矢量乘矩阵运算的光学方法。这个方法在一种新颖的光学计算结构--三值光学计算机(ternary optical computer,TOC)上,使�
资源受限环境下的适应性窗口多点乘计算方法,孙达志,,在几个主要公钥密码系统的实现中,基本而开销巨大的操作是计算定义在椭圆曲线上的某个有限加法群的多点乘问题。本文提出了一种适
MaskNet:Introducing+Feature-Wise+Multiplication+to+CTR+Ranking+Models+by+Instance-Guided+Mask
matrix multiplication (see laochanlam/matrix-multiplication in github)
BIT-PRUNING A SPARSE MULTIPLICATION-LESS DOT-PRODUCT的全文翻译
矩阵向量乘法 该算法的描述可以参考 。
Multiplication Instruction and its Usage for Computing the GCM ModeThe Intel:registered: PCLMULQDQ instruction is a new instruction available beginning with the all new 2010 Intel:registered: Core...
Faster 64-bit universal hashing using carry-less multiplicationsDaniel Lemire · Owen KaserAbstract Intel and AMD support the Carry... We also compare CLHASH with a popular hash func- tion designed for s
Lecture 9 CSE 260 – Parallel Computation(Fall 2015) Scott B. BadenPerformance modeling Further improvements to matrixmultiplicationToday’s lecture • Performance modeling ...
矩阵向量乘法使用MPI 在该代码中,矩阵和向量由具有等级0的处理器从文件中读取,矩阵的行分布在通信器中的各个处理器之间,等级0的处理器使用mpi_bcast集体调用将向量发送给所有其他处理器。 因此,每个处理器都执行...
xapp1315 lvds source synch serdes clock multiplication
combination of a simple combinatorial idea and existing fast rectangular matrix multiplication algorithms. We also obtain improved algorithms for the multiplication of more than two sparse matrices. ...
如果您不想使用缓慢的 for 循环在两个 n 维 matices 之间应用矩阵乘法,则此提交可能会有所帮助。 不幸的是,不支持单例扩展。 因此要求两个输入的大小相同。 输入 1:n-by-m-by-... 矩阵输入 2:m-by-p-by-......
用VC写的界面编程,可实现用图形纹理的设计,
Synchronous-100x100-Matrix-Multiplication-using-Multiple-Threads:开发了一个程序,用于通过使用多个线程将两个大型矩阵相乘。 之后,通过在有效时间内将整个任务划分为不同数量的线程来同步计算结果矩阵
matrix-multiplication:Java矩阵乘法
用法 $ npm install$ NODE_PATH=node_modules node index.js [DONE] RESET DATABASE[ '[DONE] generate test data: leftMatrix: ', [ { row: 0, column: 0, value: 0, _id: 54a0219b5c38d4e4722b9c8f }, { row: 0, ...