10-19 AC
This commit is contained in:
33
2010.cpp
Normal file
33
2010.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
// 1K以内的所有水仙花: 153、370、371、407
|
||||
int a,b;
|
||||
while (cin >>a>>b){
|
||||
if(b<153 || a>407 || (a>153&&b<370)||(a>371&&b<407)){
|
||||
cout <<"no" << endl;
|
||||
} else if(a<=153){
|
||||
if(b>=407)
|
||||
cout << "153 370 371 407" <<endl;
|
||||
else if(b>=371)
|
||||
cout << "153 370 371" <<endl;
|
||||
else if(b>=370)
|
||||
cout << "153 370" <<endl;
|
||||
else
|
||||
cout << "153" << endl;
|
||||
} else if(a<=370){
|
||||
if(b>=407)
|
||||
cout << "370 371 407" <<endl;
|
||||
else if(b>=371)
|
||||
cout << "370 371" << endl;
|
||||
else
|
||||
cout << "370" << endl;
|
||||
} else if(a<=371){
|
||||
if(b>=407)
|
||||
cout << "371 407" << endl;
|
||||
else
|
||||
cout << "371" << endl;
|
||||
} else
|
||||
cout << "407" << endl;
|
||||
}
|
||||
}
|
||||
20
2011.cpp
Normal file
20
2011.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int n,m;
|
||||
double t;
|
||||
cin >> n;
|
||||
for(int i=0;i<n;i++){
|
||||
t = 0;
|
||||
cin >> m;
|
||||
if(m==1){
|
||||
cout << "1.00" << endl;
|
||||
continue;
|
||||
}
|
||||
for(int j =m/2+1;j<=m-m%2;j++)
|
||||
t += 1.0/j;
|
||||
t += m%2==0?0:1.0/m;
|
||||
cout << setiosflags(ios::fixed) << setprecision(2) << t << endl;
|
||||
}
|
||||
}
|
||||
14
2012.cpp
Normal file
14
2012.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int x,y;
|
||||
// 不是素数的X仅有 40 41 44 49
|
||||
while (cin >> x >> y && (x!=0||y!=0)){
|
||||
if((x<=40&&y>=40)||(x<=41&&y>=41)||(x<=44&&y>=44)||(x<=49&&y>=49))
|
||||
cout << "Sorry"<<endl;
|
||||
else
|
||||
cout << "OK"<<endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// OJ迟迟不进行编译.....暂时就当正确吧..
|
||||
15
2013.cpp
Normal file
15
2013.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
using namespace std;
|
||||
int main(){
|
||||
// a1 = 1
|
||||
// an = 2(an-1 + 1)
|
||||
// an + 2 = 2(an-1 + 2)
|
||||
// an + 2 = 3*2^(n-1)
|
||||
// an = 3*2^(n-1) - 2
|
||||
int x;
|
||||
while (cin >> x){
|
||||
cout << 3*(long long)pow(2,x-1)-2 << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
61
2014.cpp
Normal file
61
2014.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
using namespace std;
|
||||
struct LinkNode{
|
||||
double data;
|
||||
LinkNode* next;
|
||||
};
|
||||
void swap(double &a, double &b){
|
||||
double tmp = a;
|
||||
a = b;
|
||||
b = tmp;
|
||||
}
|
||||
LinkNode* GetPartion(LinkNode* pBegin, LinkNode* pEnd)
|
||||
{
|
||||
double key = pBegin->data;
|
||||
LinkNode* p = pBegin;
|
||||
LinkNode* q = p->next;
|
||||
|
||||
while(q != pEnd)
|
||||
{
|
||||
if(q->data < key)
|
||||
{
|
||||
p = p->next;
|
||||
swap(p->data,q->data);
|
||||
}
|
||||
q = q->next;
|
||||
}
|
||||
swap(p->data,pBegin->data);
|
||||
return p;
|
||||
}
|
||||
void QuickSort(LinkNode* pBeign, LinkNode* pEnd, LinkNode* in)
|
||||
{
|
||||
if(pBeign != pEnd)
|
||||
{
|
||||
LinkNode* partion = GetPartion(pBeign,pEnd);
|
||||
QuickSort(pBeign,partion,in);
|
||||
QuickSort(partion->next,pEnd,in);
|
||||
}
|
||||
}
|
||||
void QuickSort(LinkNode* in){
|
||||
QuickSort(in, nullptr,in);
|
||||
}
|
||||
int main(){
|
||||
int n;
|
||||
double t;
|
||||
while (cin >> n){
|
||||
LinkNode *head = nullptr;
|
||||
for(int i = 0;i<n;i++){
|
||||
cin >> t;
|
||||
head = new LinkNode{t,head};
|
||||
}
|
||||
QuickSort(head = new LinkNode{0,head});
|
||||
head = head->next->next;
|
||||
t = 0;
|
||||
while (head->next){
|
||||
t += head->data;
|
||||
head = head->next;
|
||||
}
|
||||
cout << setiosflags(ios::fixed) << setprecision(2) << t/(n-2)<< endl;
|
||||
}
|
||||
}
|
||||
23
2015.cpp
Normal file
23
2015.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
// Sn = n + n*n
|
||||
// Smi =
|
||||
// bm,n = 2mn - m + 1
|
||||
int m,n;
|
||||
while (cin >> n >> m){
|
||||
int i = 1;
|
||||
for(;i<=n/m;i++){
|
||||
cout << 2*m*i - m + 1 ;cout << ((i == n/m)?"":" ");
|
||||
if(i == n/m){
|
||||
if(n%m!=0)
|
||||
cout << ' ' << (n*(n+1)-i*m*(i*m + 1))/(n%m) << endl;
|
||||
else
|
||||
cout << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
21
2016.cpp
Normal file
21
2016.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int n;
|
||||
while (cin >> n && n != 0){
|
||||
int *a = new int[n],min=0,t;
|
||||
for(int i = 0;i < n;i++){
|
||||
cin >> a[i];
|
||||
min = a[min]>=a[i]?i:min;
|
||||
}
|
||||
t = a[min];
|
||||
a[min] = a[0];
|
||||
a[0] = t;
|
||||
for(int i = 0;i < n-1;i++){
|
||||
cout << a[i] << ' ';
|
||||
}
|
||||
cout << a[n-1] << endl;
|
||||
delete[]a;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
18
2017.cpp
Normal file
18
2017.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int n;
|
||||
char in[2000] = {0};
|
||||
cin >> n;
|
||||
cin.get();
|
||||
for(int i = 0;i<n;i++){
|
||||
cin.getline(in,2000);
|
||||
int count = 0;
|
||||
char *header = in;
|
||||
for (;*header!='\0';header++)
|
||||
if(*header>='0' && *header<='9')
|
||||
count++;
|
||||
cout << count << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
24
2018.cpp
Normal file
24
2018.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
//int cow(int &c,int &w1,int &w2,int &w3,int &w4){
|
||||
// //int t = c;
|
||||
// c += w1;
|
||||
// w1 = w2;
|
||||
// w2 = w3;
|
||||
// w3 = c;
|
||||
// //w4 = t;
|
||||
// return c + w1 + w2 + w3 + w4;
|
||||
//}
|
||||
//int main(){
|
||||
// int c=1,w1=0,w2=0,w3=0,w4=0;
|
||||
// for(int i = 0;i<56;i++){
|
||||
// cout << cow(c,w1,w2,w3,w4)<< ',';
|
||||
// }
|
||||
//}
|
||||
int main(){
|
||||
int cow[]={0,1,2,3,4,6,9,13,19,28,41,60,88,129,189,277,406,595,872,1278,1873,2745,4023,5896,8641,12664,18560,27201,39865,58425,85626,125491,183916,269542,395033,578949,848491,1243524,1822473,2670964,3914488,5736961,8407925,12322413,18059374,26467299,38789712,56849086,83316385,122106097,178955183,262271568,384377665,563332848,825604416,1209982081,1773314929};
|
||||
int n;
|
||||
while (cin >>n && n!=0){
|
||||
cout << cow[n] << endl;
|
||||
}
|
||||
}
|
||||
32
2019.cpp
Normal file
32
2019.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int n,x;
|
||||
while (cin >> n >>x && (n!=0||x!=0)){
|
||||
int *i = new int[n];
|
||||
int *hea = i;
|
||||
for(int j=0;j<n;j++)
|
||||
cin >> i[j];
|
||||
int j=0;
|
||||
for(;j<n;j++){
|
||||
if(i[j] > x){
|
||||
cout << x << ' ';
|
||||
break;
|
||||
}
|
||||
cout << i[j] << ' ';
|
||||
}
|
||||
if(j==n){
|
||||
cout << x << endl;
|
||||
} else
|
||||
for(;j<n;j++){
|
||||
cout << i[j];
|
||||
if(j==n-1)
|
||||
cout << endl;
|
||||
else
|
||||
cout << ' ';
|
||||
}
|
||||
|
||||
delete[]i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user