ZZW's Blog

Step by step!


  • 首页

  • 关于

  • 标签12

  • 分类6

  • 归档22

  • 搜索

力扣刷题第1天

发表于 2019-08-20 更新于 2019-08-21 分类于 LeetCode刷题集
本文字数: 5.5k 阅读时长 ≈ 5 分钟

1. Two Sum

Description:

Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.

阅读全文 »

Hello World

发表于 2019-08-19 更新于 2020-07-03 分类于 随笔
本文字数: 356 阅读时长 ≈ 1 分钟

测试

1
2
<?php
echo "Hello World!";
阅读全文 »

费马小定理例题汇总

发表于 2019-02-09 更新于 2019-07-07 分类于 算法训练
本文字数: 2.6k 阅读时长 ≈ 2 分钟

hdu 6440 Dream

Freshmen frequently make an error in computing the power of a sum of real numbers, which usually origins from an incorrect equation $ (m+n)^p=m^p+n^p $, where m,n,p are real numbers. Let’s call it ‘’Beginner’s Dream’’.
For instance, $ (1+4)^2=5^2=25 $, but $ 1^2+4^2=17\neq25$.
Moreover, $ \sqrt{9+16}= \sqrt{25}=5 $, which does not equal $ 3+4=7 $.
Fortunately, in some cases when p is a prime, the identity $(m+n)^p=m^p+n^p $ holds true for every pair of non-negative integers m,n which are less than p, with appropriate definitions of addition and multiplication.
You are required to redefine the rules of addition and multiplication so as to make the beginner’s dream realized.
Specifically, you need to create your custom addition and multiplication, so that when making calculation with your rules the equation $ (m+n)^p=m^p+n^p $ is a valid identity for all non-negative integers m,n less than p. Power is defined as

Obviously there exists an extremely simple solution that makes all operation just produce zero. So an extra constraint should be satisfied that there exists an integer $q(0<q<p)$ to make the set ${q^k|0<k<p,k\in\mathbb{Z}}$ equal to ${k|0<k<p,k\in\mathbb{Z}}$. What’s more, the set of non-negative integers less than p ought to be closed under the operation of your definitions.

阅读全文 »

(扩展)欧拉定理例题汇总

发表于 2019-02-08 更新于 2020-07-03 分类于 算法训练
本文字数: 1.1k 阅读时长 ≈ 1 分钟

hdu 4704 Sum

Problem Description

For gievn N,let S(k) be the number of $ (x_1, x_2, \cdots ,x_k) $ which:
$ x_1, x_2, \cdots ,x_k \in \mathbb{Z}^+$
$ x_1 + x_2 + \cdots + x_k = N $
Find $ (S(1)+S(2)+\cdots+S(N)) \;mod\;(10^9+7)$.

阅读全文 »

快速幂&快速乘法取模例题汇总

发表于 2019-02-08 更新于 2020-07-03 分类于 算法训练
本文字数: 1.8k 阅读时长 ≈ 2 分钟

luogu P1226.【模板】快速幂||取余运算

题目描述:

输入b,p,k的值,求 $b^p$ mod k的值。其中b,p,k * k为长整型数。

阅读全文 »

(扩展)中国剩余定理例题汇总

发表于 2019-02-08 更新于 2020-07-03 分类于 算法训练
本文字数: 7.4k 阅读时长 ≈ 7 分钟

luogu P3868.[TJOI2009]猜数字

题目描述:

现有两组数字,每组k个,第一组中的数字分别为:$ a_1,a_2,\cdots,a_k $ 表示,第二组中的数字分别用 $ b_1,b_2,\cdots,b_k$ 表示。其中第二组中的数字是两两互素的。求最小的非负整数n,满足对于任意的 $ i,n - a_i $ 能被 $ b_i $ 整除。

阅读全文 »

快速幂&快速乘法取模模板

发表于 2019-02-07 更新于 2020-07-03 分类于 ACM模板
本文字数: 766 阅读时长 ≈ 1 分钟

快速乘法取模:$O(log^b) $

阅读全文 »

(扩展)中国剩余定理模板

发表于 2019-02-07 更新于 2020-07-03 分类于 ACM模板
本文字数: 1.6k 阅读时长 ≈ 1 分钟

中国剩余定理:$ O(nlog^n)$

阅读全文 »

(扩展)欧几里得算法模板

发表于 2019-02-07 更新于 2020-07-03 分类于 ACM模板
本文字数: 341 阅读时长 ≈ 1 分钟

欧几里得算法:$ O(log^n)$

1
2
3
4
//求两个整数的最大公约数:gcd(a, b) = gcd(b, a % b)
LL gcd(LL a, LL b) {
return b ? gcd(b, a % b) : a;
}
阅读全文 »

威尔逊定理例题汇总

发表于 2019-02-03 更新于 2020-07-03 分类于 算法训练
本文字数: 3.4k 阅读时长 ≈ 3 分钟

hdu 5391 Zball in Tina Town

Problem Description

Tina Town is a friendly place. People there care about each other.
Tina has a ball called zball. Zball is magic. It grows larger every day. On the first day, it becomes 1 time as large as its original size. On the second day,it will become 2 times as large as the size on the first day. On the n-th day,it will become n times as large as the size on the (n-1)-th day. Tina want to know its size on the (n-1)-th day modulo n.

阅读全文 »
123
wzomg

wzomg

A thousand miles begins with a single step.
22 日志
6 分类
12 标签
GitHub E-Mail 博客园 简书
Creative Commons
© 2019 – 2021 wzomg  粤ICP备19066467号-1 | 113k | 1:43
0%