代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin >> n && n)
{
int res = 0;
int t = n;
while(t > 2)
{
int t1 = t / 3;//倍数
int t2 = t % 3;//余数
res += t1;
t = t2 + t1;
}
if(t == 2) res += 1;
cout << res << endl;
}
return 0;
}
代码,
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
int t = n;
set<int> myset;
while(t--)
{
int tmp;
cin >> tmp;
myset.insert(tmp);
}
for(auto m : myset) cout << m << endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
while(cin >> s)
{
s = s.substr(2);
string str = "0123456789ABCDEF";
int res = 0;
for(int i = 0; i < s.size(); i++)
{
int t = find(str.begin(), str.end(), s[i]) - str.begin();
res += t * pow(16, s.size()-1-i);
}
cout << res << endl;
}
return 0;
}