-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a478db
commit 7b473f7
Showing
3 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
骰子魔术 | ||
|
||
https://ac.nowcoder.com/acm/contest/85598/A | ||
|
||
有一个一样的色子就可以 | ||
|
||
```cpp | ||
// By SnowDream | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
typedef long long ll; | ||
const int N=1e6+10; | ||
|
||
int main() | ||
{ | ||
ios::sync_with_stdio(false); | ||
cin.tie(nullptr); | ||
int n,x; | ||
cin >> n >> x; | ||
int a; | ||
bool ans= false; | ||
for(int i=0;i<n;++i) | ||
{ | ||
cin >> a; | ||
if(a==x) | ||
{ | ||
ans=true; | ||
} | ||
} | ||
if(ans) | ||
cout << "YES"; | ||
else | ||
cout << "NO"; | ||
cout << "\n"; | ||
return 0; | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
最少剩几个? | ||
|
||
https://ac.nowcoder.com/acm/contest/85598/B | ||
|
||
计算奇偶数数量,先一奇一偶对消,再两奇对消 | ||
|
||
```cpp | ||
// By SnowDream | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
typedef long long ll; | ||
const int N=1e6+10; | ||
int a[N]; | ||
int main() | ||
{ | ||
ios::sync_with_stdio(false); | ||
cin.tie(nullptr); | ||
int n,s1=0,s2=0; | ||
cin >> n; | ||
for(int i=0;i<n;++i) | ||
{ | ||
cin >> a[i]; | ||
if(a[i]%2==0) | ||
{ | ||
s2++; | ||
} | ||
else | ||
{ | ||
s1++; | ||
} | ||
} | ||
if(s1==s2) | ||
{ | ||
cout << 0; | ||
} | ||
else if(s1<s2) | ||
{ | ||
cout << s2-s1; | ||
} | ||
else | ||
{ | ||
int tmp=s1-s2; | ||
if(tmp%2==0) | ||
cout << 0; | ||
else | ||
cout << 1; | ||
} | ||
cout << "\n"; | ||
return 0; | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
两个函数 | ||
|
||
https://ac.nowcoder.com/acm/contest/85598/C | ||
|
||
数学方程化简 | ||
|
||
```cpp | ||
// By SnowDream | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
typedef long long ll; | ||
const int N=1e6+10; | ||
ll a,x; | ||
ll fun() | ||
{ | ||
if(x==1) | ||
{ | ||
return a%998244353; | ||
} | ||
ll tmp1 = a*a%998244353; | ||
ll tmp2 = (x*(x-1))/2%998244353; | ||
return tmp1*tmp2%998244353; | ||
} | ||
int main() | ||
{ | ||
ios::sync_with_stdio(false); | ||
cin.tie(nullptr); | ||
int t; | ||
cin >> t; | ||
while(t--) | ||
{ | ||
cin >> a >> x; | ||
cout << fun() << "\n"; | ||
} | ||
return 0; | ||
} | ||
``` | ||
|