#include<iostream>
using namespace std;
#include<vector>
int arr[100001] = {};
struct zu
{
int m_Num1;
int m_Num2;
};
int main()
{
int num1, num2;
int k;
cin >> k;
vector<zu>v;
zu z;
int flag;
int times;
for (int i = 0;i < k;i++)
{
cin >> num1 >> num2;
z.m_Num1 = num1;
z.m_Num2 = num2;
v.push_back(z);
}
for (vector<zu>::iterator it = v.begin();it != v.end();it++)
{
for (int i = 0;i < 100001;i++)
{
arr[i] = 0;
}
arr[100000] = 1;
for (int i = (*it).m_Num1;i >= 1;i--)
{
for (int j = 100000;j >= 0;j--)
{
arr[j] *= i;
}
for (int j = 100000;j >= 1;j--)
{
if (arr[j] >= 10)
{
arr[j - 1] += (arr[j] / 10);
arr[j] %= 10;
}
}
}
flag = 0;
times = 0;
while (arr[flag] == 0)
{
flag++;
}
for (int j = 100000;j >= flag;j--)
{
if (arr[j] == (*it).m_Num2)
{
times++;
}
}
cout << times++ << endl;
}
system("pause");
return 0;
}
?
#include<iostream>
using namespace std;
#include<set>
int arr[100001] = {};
int main()
{
int n;
cin >> n;
int start = 2;
int sum = 0;
multiset<int>mu;
while (sum < n)
{
sum += start;
if (sum <= n)
{
mu.insert(start);
start++;
}
else if (sum > n)
{
int flag = sum - n;
if (flag == 1)
{
mu.erase(2);
start++;
mu.insert(start);
break;
}
else
{
mu.erase(flag);
mu.insert(start);
break;
}
}
}
arr[100000] = 1;
for (multiset<int>::iterator it = mu.begin();it != mu.end();it++)
{
cout << *it << " ";
for (int i = 100000;i >= 0;i--)
{
arr[i] *= (*it);
}
for (int i = 100000;i >= 1;i--)
{
if (arr[i] >= 10)
{
arr[i - 1] += (arr[i] / 10);
arr[i] %= 10;
}
}
}
int flag = 0;
while (arr[flag] == 0)
{
flag++;
}
cout << endl;
for (int i = flag;i < 100001;i++)
{
cout << arr[i];
}
cout << endl;
system("pause");
return 0;
}
?
#include<iostream>
using namespace std;
#include<vector>
#include<string>
#include<algorithm>
struct people
{
string m_Name;
string m_Carrer;
int m_Bangong;
int m_Dgree;
};
bool mycompareByDgree(const people& peo1, const people& peo2)
{
return peo1.m_Dgree > peo2.m_Dgree;
}
bool mycompareByDgree2(const people& peo1, const people& peo2)
{
if (peo1.m_Dgree == peo2.m_Dgree)
{
return peo1.m_Bangong > peo2.m_Bangong;
}
return peo1.m_Dgree > peo2.m_Dgree;
}
bool mycompareByBangong(const people& peo1, const people& peo2)
{
return peo1.m_Bangong > peo2.m_Bangong;
}
int main()
{
int n;
cin >> n;
people p1;
vector<people>v_result;
string name, carrer;
int bangong, dgree;
cin >> name >> carrer;
cin >> bangong >> dgree;
p1.m_Bangong = bangong;
p1.m_Carrer = carrer;
p1.m_Dgree = dgree;
p1.m_Name = name;
v_result.push_back(p1);
vector<people>v1;
for (int i = 0;i < 2;i++)
{
cin >> name >> carrer;
cin >> bangong >> dgree;
p1.m_Bangong = bangong;
p1.m_Carrer = carrer;
p1.m_Dgree = dgree;
p1.m_Name = name;
v1.push_back(p1);
}
sort(v1.begin(), v1.end(),mycompareByDgree);
for (vector<people>::iterator it = v1.begin();it != v1.end();it++)
{
v_result.push_back(*it);
}
vector<people>v2;
for (int i = 0;i < n-3;i++)
{
cin >> name >> carrer;
cin >> bangong >> dgree;
p1.m_Bangong = bangong;
p1.m_Carrer = carrer;
p1.m_Dgree = dgree;
p1.m_Name = name;
v2.push_back(p1);
}
sort(v2.begin(), v2.end(), mycompareByBangong);
vector<people>::iterator pos = v2.begin();
vector<people>HuFa;
vector<people>ZhangLao;
vector<people>TangZhu;
vector<people>JingYing;
vector<people>BangZhong;
//for (vector<people>::iterator it = v2.begin();it != v2.end();it++)
for (int i = 0;i < n - 3;i++)
{
if (i < 2)
{
(*pos).m_Carrer = "HuFa";
HuFa.push_back(*pos);
}
else if(i<6)
{
(*pos).m_Carrer = "ZhangLao";
ZhangLao.push_back(*pos);
}
else if (i < 13)
{
(*pos).m_Carrer = "TangZhu";
TangZhu.push_back(*pos);
}
else if (i < (13 + 25))
{
(*pos).m_Carrer = "JingYing";
JingYing.push_back(*pos);
}
else
{
(*pos).m_Carrer = "BangZhong";
BangZhong.push_back(*pos);
}
pos++;
}
sort(HuFa.begin(), HuFa.end(), mycompareByDgree2);
sort(ZhangLao.begin(), ZhangLao.end(), mycompareByDgree2);
sort(TangZhu.begin(), TangZhu.end(), mycompareByDgree2);
sort(JingYing.begin(), JingYing.end(), mycompareByDgree2);
sort(BangZhong.begin(), BangZhong.end(), mycompareByDgree2);
for (vector<people>::iterator it = HuFa.begin();it != HuFa.end();it++)
{
v_result.push_back(*it);
}
for (vector<people>::iterator it = ZhangLao.begin();it != ZhangLao.end();it++)
{
v_result.push_back(*it);
}
for (vector<people>::iterator it = TangZhu.begin();it != TangZhu.end();it++)
{
v_result.push_back(*it);
}
for (vector<people>::iterator it = JingYing.begin();it != JingYing.end();it++)
{
v_result.push_back(*it);
}
for (vector<people>::iterator it = BangZhong.begin();it != BangZhong.end();it++)
{
v_result.push_back(*it);
}
for (vector<people>::iterator it = v_result.begin();it != v_result.end();it++)
{
cout << (*it).m_Name << " " << (*it).m_Carrer << " " << (*it).m_Dgree << endl;
}
system("pause");
return 0;
}
?
?