锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
//鐢ㄤ簬璁$畻浠?鍒版煇涓暟瀛梟涓敤鍒?0,1,2,3,4,5,6,7,8,9)鐨勪釜鏁?br>
//浣跨敤鍓嶆敞鎰忓皢鏁扮粍a鍒濆鍖栦負0,鍗蟲瘡涓暟瀛楀嚭鐜扮殑涓暟鏄?
void Count(int a[10],int n) //緇撴灉瀛樺湪a鏁扮粍涓?鍏朵腑a[0]瀛?鐨勪釜鏁?#8230;

{
int i,m,b,l,p;
b=1;
l=0;
p=0;
while(n)
{
p=p*10+1;
m=n%10;
n=n/10;
for(i=0;i<m;i++)
a[i]+=b;
a[m]=a[m]+l+1;
for(i=0;i<10;i++)
a[i]+=n*b;
l=l+m*b;
b=b*10;
}
a[0]=a[0]-p;
}
]]>
]]>
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;

int st[83][83];
int main()

{
int n;
__int64 m;
while(scanf("%d%I64d",&n,&m) != EOF)
{
if(n == 0 && m == 0)
break;
int i,j,pp;
char str[90],temp[83];
int sh[83],xia[83];
for(i = 0;i < n;i++)
{
scanf("%d",&pp);
pp--;
sh[i] = pp;
xia[pp] = i;//
}
getchar();
cin.getline(str,82,'\n');
for(i = 0; i < n;i++)
{
j = xia[i];
pp = 1;
while(i != j)
{
st[i][pp++] = j;
j = xia[j];
}
st[i][pp] = st[i][pp+1] = j;
st[i][0] = pp;//寰幆嬈℃暟
}
for(i = 0; i < n;i++)
{
if(m % st[i][0] == 0)
pp = st[i][0];
else
{
pp = m % st[i][0];
pp = st[i][0] - pp;
}
temp [st[i][pp]] = str[i];
}
temp[n] = '\0';
printf("%s\n",temp);
}
return 0;
}
]]>
#include<iostream>
#include<cstdio>
using namespace std;
__int64 a[51];
__int64 sum;
int main()

{
int n;
while(cin>>n)
{
if(n == 0)
break;
int i;
sum = 0;
for(i = 1;i <= n;i++)
scanf("%I64d",&a[i]);
while(n > 0)
{
for(i = 1; i < n;i++)//浠庢渶鍚庡紑鏃朵竴嬈″線i-1鍔燼[i]
a[i] = a[i] + a[n];
sum = sum + a[n];
n--;
}
printf("%I64d\n",sum);
}
return 0;
}
]]>
#include<iostream>
using namespace std;
int exgcd(int a,int b,int &x,int &y)//姹傛渶澶у叕綰︽暟

{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int r = exgcd(b,a%b,x,y);
int t = x;
x = y;
y = t - a/b*y;
return r;
}
int main()

{
int a,b,m,n,r;
while(cin>>a>>b)
{
int i;
r = exgcd(a,b,m,n);
if(r == 1)
{
while(m < 0)
{
m += b;
n -= a;
}
printf("%d %d\n",m,n);
}
else
cout<<"sorry"<<endl;
}
return 0;
}
]]>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef struct 

{
double x;
double y;
}pttype;
const long maxsize = 100000;
long arr[maxsize];
long arr1;
pttype pt[maxsize];
int sortcmp(const void *a, const void *b)

{
if (((pttype*)a)->x < ((pttype*)b)->x)
return -1;
else
return 1;
}
double dis(pttype a,pttype b)

{
return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}
double getMin(double a, double b)

{
if(a<b)
return a;
else
return b;
}
int arrcmp(const void *a, const void *b)

{
if (pt[*(int*)a].y < pt[*(int*)b].y)
return -1;
else
return 1;
}
double shortest(long left,long right)

{
if(right-left == 1)
return dis(pt[left],pt[right]);
if(right-left == 2)
return getMin(getMin(dis(pt[left], pt[left+1]), dis(pt[left], pt[right])), dis(pt[left+1], pt[right]));
long i,j,mid = (left + right) >> 1;
double curmin = getMin(shortest(left,mid),shortest(mid +1 ,right));
arr1 = 0;
for (i = mid; i >= left && pt[mid+1].x - pt[i].x <= curmin; i --)
arr[arr1++] = i;
for (i = mid + 1; i <= right && pt[i].x - pt[mid].x <= curmin; i ++)
arr[arr1++] = i;
qsort(arr, arr1, sizeof(arr[0]), arrcmp);
for (i = 0; i < arr1; i ++)
for (j = i + 1; j < arr1 && pt[arr[j]].y - pt[arr[i]].y <= curmin; j ++)
curmin = getMin(curmin, dis(pt[arr[i]], pt[arr[j]]));
return curmin;
}
int main()

{
long n,i;
while(1)
{
scanf("%d",&n);
if(n == 0)
break;
for(i = 0;i < n;i++)
scanf("%lf%lf",&pt[i].x,&pt[i].y);
qsort(pt,n,sizeof(pt[0]),sortcmp);
printf("%.2lf\n",shortest(0,n-1)/2);
}
return 0;
}
]]>
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<cmath>
#include<algorithm>
using namespace std;
const double eps = 1E-6;//璇樊闄?/span>
struct Line 

{
double a;
double b;
};
struct Point 

{
double x;
double y;
};
void readReal(double &v)

{
scanf("%lf",&v);
}
bool operator < (Line const &l1,Line const &l2)

{ //鏂滅巼涓轟富搴忥紙浠庡皬鍒板ぇ錛?/span>
if(l1.a < l2.a)
return true;
if(l1.a > l2.a)
return false;
//鎴窛涓烘搴忥紙浠庡ぇ鍊掑皬錛屼篃鍗充粠楂樺埌浣庯級
return l1.b > l2.b;
}
double y_at_x(Line const &line,double x)

{//榪斿洖鐩寸嚎line鍦▁澶勭殑y鍊?/span>
return line.a*x + line.b;
}
Point intersection(Line const &l1,Line const &l2 )

{//姹傜洿綰縧1鍜宭2鐨勪氦鐐?/span>
Point p;
p.x = (l1.b - l2.b)/(l2.a - l1.a);
p.y = y_at_x(l1,p.x);
return p;
}
int count(vector<Line> &L)

{//緇熻鏈夊灝戞潯鍙褰╄櫣
if(L.size() < 2) // 澶勭悊騫沖嚒鎯呭艦
return L.size();
// 澶勭悊闈炲鉤鍑℃儏褰?br>
// 棣栧厛瀵圭洿綰挎寜鏂滅巼閫掑鎺掑簭(騫寵鏃舵埅璺濆ぇ鑰呬紭鍏?
sort(L.begin(),L.end());
stack<Line> lines;// 鍗婂鉤闈㈡墍浜ゅ嚫鍩熺殑杈規墍鍦ㄧ洿綰?/span>
stack<Point> points;// 鍗婂鉤闈㈡墍浜ゅ嚫鍩熺殑欏剁偣
lines.push(L.front());// 娣誨姞絎竴鏉$洿綰夸綔涓虹害鏉?/span>
for(vector<Line>::iterator iter = L.begin() + 1;iter != L.end();iter++)
{// 涓嶆柇娣誨姞鐩寸嚎綰︽潫
while(!points.empty())// 鍘婚櫎澶氫綑綰︽潫 -- 娉ㄦ剰璇樊澶勭悊
{// 鍏堝鐞嗗嚭鐜板鉤琛岀洿綰跨殑鎯呭艦
if(fabs(iter->a - lines.top().a) < eps)
break;
// 澶勭悊涓嶅惈騫寵鐩寸嚎鐨勬儏褰?/span>
Point tmp = points.top();
if(y_at_x(*iter,tmp.x) < tmp.y - eps)
break;
else
{
lines.pop();
points.pop();
}
}
// 娣誨姞褰撳墠闈炲鉤琛岀洿綰夸綔涓烘柊鐨勭害鏉?/span>
if(fabs(iter->a - lines.top().a) > eps)
{
points.push(intersection(*iter,lines.top()));
lines.push(*iter);
}
}
// 鍑稿煙鐨勮竟鏁板嵆鏄鐩姹傝В鐨?#8220;鍙”褰╄櫣鏉℃暟
return lines.size();
}
int main()

{
int text;
cin>>text;
while(text--)
{
int n;
int i;
scanf("%d",&n);
vector<Line> L(n);//鐩寸嚎闆嗗悎
for(i = 0;i < n;i++)
{
readReal(L[i].a);
readReal(L[i].b);
}
printf("%d\n",count(L));
}
return 0;
}
]]>
#include<iostream>
#include<cmath>
using namespace std;
typedef struct node

{
double x,y,z;
double I;
}Node;
Node point[101];
double distence(Node c,double a,double b)

{
double sum = (c.x - a)*(c.x - a)+(c.y - b)*(c.y - b)+c.z*c.z;//璁$畻鍏夋簮鐐瑰埌鍦伴潰鐐圭殑璺濈
return sum;
}
int main()

{
int text;
cin>>text;
while(text--)
{
int n;
int i,j,k;
cin>>n;
double maxs = 0.0;
for(i =1; i <= n;i++)
cin>>point[i].x>>point[i].y>>point[i].z>>point[i].I;
for(i = -100;i <= 100;i++)//鏋氫婦xy騫抽潰涓婁粠-100鍒?00鐨剎y鎵鏈夌殑鐐癸紝鎵懼嚭鏈澶х殑
for(j = -100;j <= 100;j++)
{
double sum = 0.0;
for(k = 1;k <= n;k++)
{
double R;
R = distence(point[k],i,j);
sum += (point[k].I /(R))*(point[k].z/sqrt(R));//璁$畻鍏夊己搴?/span>
}
if(sum > maxs)
maxs = sum;
}
printf("%.2lf\n",maxs);
}
return 0;
}
]]>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
typedef struct node

{
string ss;
int par;
int pri;
int num;
friend bool operator < (node a,node b)
{
if(a.pri != b.pri)
return a.pri > b.pri;
else
return a.num >b.num;
}
}Node;
int main()

{
string str;
priority_queue<Node> Q;
int k=1;
while(cin>>str)
{
Node p,q;
if(str == "GET")
{
if(!Q.empty())
{
q = Q.top();
Q.pop();
cout<<q.ss<<" "<<q.par<<endl;
}
else
{
cout<<"EMPTY QUEUE!"<<endl;
}
}
if(str == "PUT")
{
string str1;
int a,b;
cin>>str1>>a>>b;
p.ss = str1;
p.par = a;
p.pri = b;
p.num = k;
Q.push(p);
k++;
}
}
return 0;
}
]]>