10-4 요약

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">T1</span>

하?나체
그리고 T가 됐어요.걸리다
dij:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ext/pb_ds/priority_queue.hpp>
#define ll long long
#define pa pair<ll,int>
#define llinf 9000000000000000000LL
using namespace std;
using namespace __gnu_pbds;
typedef __gnu_pbds::priority_queue<pa,greater<pa>,pairing_heap_tag > heap;
int n,m,cnt,first[2000005],s[2000005];
heap::point_iterator id[2000005];
int x,y,z,k;
ll dis[2000005];heap q;
struct data{int to,next,v;}e[2000005];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void insert(int u,int v,int w)
{
    e[++cnt].to=v;e[cnt].next=first[u];first[u]=cnt;e[cnt].v=w;
}
void dijkstra()
{
    while(!q.empty())
    {
        int now=q.top().second;q.pop();
        for(int i=first[now];i;i=e[i].next)
            if(e[i].v+dis[now]<dis[e[i].to])
            {
                dis[e[i].to]=e[i].v+dis[now];
                if(id[e[i].to]!=0)
                    q.modify(id[e[i].to],make_pair(dis[e[i].to],e[i].to));
                else id[e[i].to]=q.push(make_pair(dis[e[i].to],e[i].to));
            }
    }
}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int a,b;
    n=read();m=read();k=read();
    for(int i=1;i<=n;i++) dis[i]=llinf;
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&s[i]);
        dis[s[i]]=0;
        id[s[i]]=q.push(make_pair(0,s[i]));
    }
    for(int i=1;i<=m;i++)
    {
        x=read(),y=read(),z=read();
        insert(x,y,z);
        insert(y,x,z);
    }
    dijkstra();
    for(int i=1;i<=n;i++)
     cout<<dis[i]<<' ';
    return 0;
}
spfa(T)
//Copyright(c)2015 liuchenrui
#include<cstdio>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<ext/pb_ds/priority_queue.hpp>
#define inf 1000000000
using namespace std;
__gnu_pbds::priority_queue< pair<int,int> >que;
inline void R(int &v)
{
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
struct Edge{int to,len,next;}edge[400010];
int dis[100010],size;
int first[100010];
bool exsit[100010];
int n,m,k;
int du[1000010];
void addedge(int x,int y,int z)
{
	size++;
	edge[size].len=z;
	edge[size].to=y;
	edge[size].next=first[x];
	first[x]=size;
}
int main()
{
	freopen("flood.in","r",stdin);
	freopen("flood.out","w",stdout);
	srand(time(0));
	fill(dis,dis+100005,inf);
	R(n),R(m),R(k);
	for(int x,i=1;i<=k;i++)R(x),addedge(0,x,0);
	for(int x,y,z,i=1;i<=m;i++)R(x),R(y),R(z),addedge(x,y,z),addedge(y,x,z);
	dis[0]=0;
	que.push(make_pair(rand(),0));
	while(!que.empty())
	{
		int x=que.top().second;
		que.pop();
		exsit[x]=false;
		for(int u=first[x];u;u=edge[u].next)
		{
			int r=dis[x]+edge[u].len;
			if(dis[edge[u].to]>r)
			{
				dis[edge[u].to]=r;
				if(!exsit[edge[u].to] && du[edge[u].to]<=100)
				{
					du[edge[u].to]++;
					exsit[edge[u].to]=true;
					que.push(make_pair(rand(),edge[u].to));
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d ",dis[i]);
	}
}

T2
오늘 spfa 전체!?
그리고 또 티가 났어요. (너 또 끊겨) 80.
//Copyright(c)2015 liuchenrui
//Dev c++ 5.5.3
//test 2015.9.26
#include<cstring>
#include<stdio.h>
#include<time.h>
#include<iostream>
#include<algorithm>
#define ll long long
#define lson(v) t[v].lson
#define rson(v) t[v].rson
#define N 2147483647ll
#define rep(i,n) for(ll i=1;i<=n;i++)
using namespace std;
inline void R(ll &v)
{
	v=0;char c=0;ll p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
ll root[100010];
ll tot,x;
ll n,m;
struct Tree
{
	ll lson,rson,size;
	Tree(){lson=0,rson=0,size=0;}
}t[5000010];
void update(ll v)
{
	t[v].size=t[lson(v)].size+t[rson(v)].size;
}
void build(ll prev,ll now,ll l,ll r,ll val)
{
	if(l==r){t[now].size=t[prev].size+1;return;}
	ll mid=l+r>>1;
	if(val<=mid)
	{
		t[now].rson=t[prev].rson;
		t[now].lson=++tot;
		build(t[prev].lson,t[now].lson,l,mid,val);
	}
	else
	{
		t[now].lson=t[prev].lson;
		t[now].rson=++tot;
		build(t[prev].rson,t[now].rson,mid+1,r,val);
	}
	update(now);
}
ll query(ll prev,ll now,ll l,ll r,ll kth)
{
	if(l==r)return l;
	ll mid=l+r>>1;
	if(t[lson(now)].size-t[lson(prev)].size>=kth)return query(t[prev].lson,t[now].lson,l,mid,kth);
	else return query(t[prev].rson,t[now].rson,mid+1,r,kth-(t[lson(now)].size-t[lson(prev)].size));
}
ll sum;
char c[1];
int main()
{
	freopen("xxx.in","r",stdin);
	freopen("xxx.out","w",stdout);
	R(n),R(m);
	ll t=0;
	rep(i,n)
	{
		scanf("%s",c);
		if(c[0]=='A')
		{
			ll x;R(x);
			x=(x+t)%m;
			root[++sum]=++tot;
			build(root[sum-1],root[sum],0,N,x);
		}
		else
		{
			ll x;R(x);
			t=query(root[sum-x],root[sum],0,N,x);
			printf("%d
",t); } } }

정해
//Copyright(c)2015 liuchenrui
#include<cstdio>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstring>
#define rep(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=2;i<=n;i++)
#define epr(i,n) for(int i=n-1;i>=1;i--)
using namespace std;
inline void R(long long &v)
{
	v=0;char c=0;long long p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
long long w[1005][1005],dp[1005][1005],n,m;
int main()
{
	R(n),R(m);
	rep(i,n)rep(j,m)R(w[i][j]);
	dp[1][1]=w[1][1];
	per(i,n)dp[i][1]=dp[i-1][1]+w[i][1];
	per(i,m)
	{
		rep(j,n)dp[j][i]=dp[j][i-1]+w[j][i];
		per(j,n)dp[j][i]=min(dp[j][i],dp[j-1][i]+w[j][i]);
		epr(j,n)dp[j][i]=min(dp[j][i],dp[j+1][i]+w[j][i]);
	}
	cout<<dp[n][m];
	return 0;
}

T3 소수 고정밀
//Copyright(c)2015 liuchenrui
#include<cstdio>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define to first
#define len second
#include<vector>
#include<queue>
#define eps 1e-8
#define rep(i,n) for(int i=1;i<=n;i++)
using namespace std;
inline void R(int &v)
{
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3ll)+(v<<1ll)+c-'0';c=getchar();}
	v*=p;
}
namespace f
{
	const int Mint=200;
	const int Mdec=100;
	const int Mlim=100;
	const int MAXD=10000;
	const int dig=10;
	struct bignum
	{
		int tail;
		int a[MAXD];
		inline void clear(){memset(a,0,sizeof(a));tail=1;}
		bignum(){memset(a,0,sizeof(a));tail=1;}
		inline operator int()
		{
			int x=0;
			for(int i=tail;i>=1;i--){x*=10;x+=a[i];}
			return x;
		}
		inline bignum operator = (const char *num)
		{
			this->clear();
			int len=strlen(num);
			for(int i=1;i<=len;i++)this->a[i]=num[len-i]-'0';
			this->tail=len;
			return *this;
		}
		inline bignum operator = (const int NUM)
		{
			this->clear();
			int s=0;
			int num=NUM;
			if(num==0){this->tail=1;return *this;}
			while(num!=0){this->a[++s]=num%dig;num/=dig;}
			this->tail=s;
			return *this;
		}
		inline void get()
		{
			int b[MAXD],tin=0;
			char c;
			for(c=getchar();c<'0' || c>'9';c=getchar());
			for(;c>='0' && c<='9';c=getchar())b[++tin]=c-'0';
			for(int i=tin;i>=1;i--)a[tin-i+1]=b[i];
			tail=tin;
		}
		inline void put()
		{
			if(tail==1 && a[1]==0){printf("0");return;}
			for(int i=tail;i>=1;i--)printf("%d",a[i]);
		}
		inline bool operator < (const bignum b)
		{
			if(tail<b.tail)return true;
			if(tail>b.tail)return false;
			for(int i=tail;i>=1;i--)
			{
				if(a[i]<b.a[i])return true;
				if(a[i]>b.a[i])return false;
			}
			return false;
		}
		inline bool operator > (const bignum b)
		{
			if(tail<b.tail)return false;
			if(tail>b.tail)return true;
			for(int i=tail;i>=1;i--)
			{
				if(a[i]<b.a[i])return false;
				if(a[i]>b.a[i])return true;
			}
			return false;
		}
		inline bool operator == (const bignum b)
		{
			if(tail<b.tail)return false;
			if(tail>b.tail)return false;
			for(int i=tail;i>=1;i--)
			{
				if(a[i]<b.a[i])return false;
				if(a[i]>b.a[i])return false;
			}
			return true;
		}
		inline bool operator != (const bignum b){return !(*this==b);}
		inline bool operator >= (const bignum b){return !(*this<b);}
		inline bool operator <= (const bignum b){return !(*this>b);}
		inline bignum operator + (const bignum b)
		{
			bignum c;
			int maxx=max(this->tail,b.tail);
			for(int i=1;i<=maxx;i++)
			{
				c.a[i]=this->a[i]+b.a[i]+c.a[i];
				if(c.a[i]>=dig)
				{
					c.a[i]-=dig;
					c.a[i+1]++;
					if(i==maxx)maxx++;
				}
			}
			c.tail=maxx;
			return c;
		}
		inline bignum operator - (const bignum b)
		{
			bignum c;
			int max=this->tail;
			for(int i=1;i<=max;i++)c.a[i]=this->a[i]-b.a[i];
			for(int i=1;i<=max;i++)
			{
				if(c.a[i]<0)
				{
					c.a[i]+=dig;
					c.a[i+1]--;
				}
				if(c.a[i]>0)c.tail=i;
			}
			return c;
		}
		inline bignum &operator += (const bignum &b){*this=*this+b;return *this;}
		inline bignum &operator -= (const bignum &b){*this=*this-b;return *this;}
		inline bignum operator * (const bignum b)
		{
			bignum c;
			if((this->tail==1 && this->a[1]==0) || (b.tail==1 && b.a[1]==0)){c.tail=1;return c;}
			int l1=this->tail;
			int l2=b.tail;
			int maxx=0;
			for(int i=1;i<=l1;i++)
			{
				for(int j=1;j<=l2;j++)
				{
					c.a[i+j-1]+=this->a[i]*b.a[j];
					maxx=max(maxx,i+j-1);
				}
			}
			for(int i=1;i<=maxx;i++)
			{
				if(c.a[i]>=dig)
				{
					c.a[i+1]+=c.a[i]/dig;
					c.a[i]%=dig;
					if(i==maxx)maxx++;
				}
			}
			c.tail=maxx;
			return c;
		}
		inline bignum operator / (const int b)
		{
			int x=0;
			bignum c;
			for(int i=this->tail;i>=1;i--)
			{
				x*=dig;
				x+=this->a[i];
				c.a[i]=x/b;
				if(c.tail==1)if(c.a[i]!=0)c.tail=i;
				x=x%b;
			}
			return c;
		}
		inline int operator % (const int b)
		{
			int x=0;
			bignum c;
			for(int i=this->tail;i>=1;i--)
			{
				x*=dig;
				x+=this->a[i];
				c.a[i]=x/b;
				if(c.tail==1)if(c.a[i]!=0)c.tail=i;
				x=x%b;
			}
			return x;
		}
		inline bignum operator / (const bignum b)
		{
			bignum c,d,l;
			bignum k;
			k=dig;
			for(int i=this->tail;i>=1;i--)
			{
				c=c*k;
				l=this->a[i];
				c+=l;
				while(c>=b)
				{
					d.a[i]++;
					if(d.tail==1)d.tail=i;
					c-=b;
				}
			}
			return d;
		}
		inline bignum operator % (const bignum b)
		{
			bignum c,d,l;
			bignum k;
			k=dig;
			for(int i=this->tail;i>=1;i--)
			{
				c=c*k;
				l=this->a[i];
				c+=l;
				while(c>=b)
				{
					d.a[i]++;
					if(d.tail==1)d.tail=i;
					c-=b;
				}
			}
			return c;
		}
		inline bignum operator *= (const bignum b){*this=(*this*b);return *this;}
		inline bignum operator /= (const bignum b){*this=(*this/b);return *this;}
		inline bignum operator %= (const bignum b){*this=(*this%b);return *this;}
		inline bignum operator /= (const int b){*this=(*this/b);return *this;}
		inline bignum operator %= (const int b){*this=(*this%b);return *this;}
	};
	std::ostream &operator << (std::ostream &out,bignum &a){a.put();return out;}
	std::istream &operator >> (std::istream &in,bignum &a){a.get();return in;}
	struct decimal
	{
		int head,tail;
		int a[Mint],b[Mdec];
		inline void clear()
		{
			memset(a,0,sizeof(a));
			memset(b,0,sizeof(b));
			head=1,tail=1;
		}
		decimal()
		{
			memset(a,0,sizeof(a));
			memset(b,0,sizeof(b));
			head=1,tail=1;
		}
		inline decimal operator = (const char *p)
		{
			this->clear();
			int len=strlen(p);
			int k=0;
			while(p[k]!='.')k++;
			this->head=k;this->tail=len-k-1;
			for(int i=k-1;i>=0;i--)this->a[k-i]=p[i]-'0';
			for(int i=k+1;i<len;i++)this->b[i-k]=p[i]-'0';
			return *this;
		}
		inline decimal operator = (const int p)
		{
			this->clear();
			this->head=0;
			int u=p;
			while(u!=0)
			{
				this->a[++this->head]=u%10;
				u/=10;
			}
			if(this->head==0)this->head=1;
			return *this;
		}
		inline decimal operator = (const double p)
		{
			int u=int(floor(p));
			this->head=0;
			this->tail=0;
			while(u!=0)
			{
				this->a[++this->head]=u%10;
				u/=10;
			}
			if(this->head==0)this->head=1;
			double k=p-floor(p);
			double e=0.1;
			while(fabs(k)>eps)
			{
				this->tail++;
				while(k>e)
				{
					k-=e;
					this->b[this->tail]++;
				}
				e/=10;
			}
			if(this->tail==0)this->tail=1;
		}
		inline void print(int num)
		{
			for(int i=head;i>=2;i--)printf("%d",a[i]);
			if(num==0){printf("%d",b[1]>=5?a[1]+1:a[1]);return;}
			if(num!=0)printf("%d.",a[1]);
			for(int i=1;i<num;i++)printf("%d",b[i]);
			if(b[num+1]>=5)printf("%d",b[num]+1);
			else printf("%d",b[num]);
		}
		inline void get()
		{
			int l[Mint],r[Mdec];
			int p=0;
			char c;
			for (c=getchar();c<'0'||c>'9';c=getchar());
			for (;c>='0'&&c<='9';c=getchar())l[++p]=c-'0';
			for(int i=p;i>=1;i--)a[p-i+1]=l[i];
			head=p;tail=1;p=0;
			if(c=='.')
			for (c=getchar();c>='0'&&c<='9';c=getchar())b[++p]=c-'0';
			tail=p;
			if(tail==0)tail=1;
		}
		inline bool operator < (const decimal p)
		{
			if(this->head!=p.head)return this->head<p.head;
			for(int i=p.head;i>=1;i--)if(this->a[i]!=p.a[i])return this->a[i]<p.a[i];
			int y=max(this->tail,p.tail);
			for(int i=1;i<=y;i++)if(this->b[i]!=p.b[i])return this->b[i]<p.b[i];
			return false;
		}
		inline bool operator > (const decimal p)
		{
			if(this->head!=p.head)return this->head>p.head;
			for(int i=p.head;i>=1;i--)if(this->a[i]!=p.a[i])return this->a[i]>p.a[i];
			int y=max(this->tail,p.tail);
			for(int i=1;i<=y;i++)if(this->b[i]!=p.b[i])return this->b[i]>p.b[i];
			return false;
		}
		inline bool operator == (const decimal p)
		{
			if(this->head!=p.head)return false;
			for(int i=p.head;i>=1;i--)if(this->a[i]!=p.a[i])return false;
			int y=max(this->tail,p.tail);
			for(int i=1;i<=y;i++)if(this->b[i]!=p.b[i])return false;
			return true; 
		}
		inline bool operator != (const decimal b){return !(*this==b);}
		inline bool operator >= (const decimal b){return !(*this<b);}
		inline bool operator <= (const decimal b){return !(*this>b);}
		inline decimal operator + (const decimal p)
		{
			decimal x;
			int l=max(this->head,p.head),r=max(this->tail,p.tail);
			for(int i=r;i>=1;i--){x.b[i]=this->b[i]+p.b[i]+x.b[i];if(x.b[i]>=10){x.b[i]-=10;x.b[i-1]++;}}
			x.tail=r;
			if(x.b[0]==1)x.a[1]=1;
			for(int i=1;i<=l;i++){x.a[i]=this->a[i]+p.a[i]+x.a[i];if(x.a[i]>=10){x.a[i]-=10;x.a[i+1]++;if(i==l)l++;}}
			x.head=l;
			return x;
		}
		inline decimal operator - (const decimal p)
		{
			decimal x;
			int r=max(this->tail,p.tail);
			for(int i=r;i>=1;i--){x.b[i]=x.b[i]+this->b[i]-p.b[i];if(x.b[i]<0){x.b[i]+=10;x.b[i-1]--;}}
			while(r>=2 && x.b[r]!=0)r--;
			x.tail=r;
			if(x.b[0]<0){x.b[0]=0;x.a[1]--;}
			for(int i=1;i<=this->head;i++)
			{x.a[i]=x.a[i]+this->a[i]-p.a[i];if(x.a[i]<0){x.a[i]+=10;x.a[i+1]--;}if(x.a[i]!=0)x.head=i;}
			return x;
		}
		inline decimal &operator += (const decimal &b){*this=*this+b;return *this;}
		inline decimal &operator -= (const decimal &b){*this=*this-b;return *this;}
		inline decimal operator * (decimal p)
		{
			decimal x;
			while(this->b[this->tail]==0 && this->tail!=1)this->tail--;
			while(p.b[p.tail]==0 && p.tail!=1)p.tail--;
			int l[Mint+Mdec],r[Mint+Mdec],k[Mint+Mdec],l1=0,l2=0,l3;
			for(int i=this->tail;i>=1;i--)l[++l1]=this->b[i];
			for(int i=p.tail;i>=1;i--)r[++l2]=p.b[i];
			for(int i=1;i<=this->head;i++)l[++l1]=this->a[i];
			for(int i=1;i<=p.head;i++)r[++l2]=p.a[i];
			for(int i=1;i<=l1;i++)for(int j=1;j<=l2;j++)k[i+j-1]+=l[i]*r[j];
			for(int i=1;i<=l1+l2+3;i++){if(k[i]>=10){k[i+1]+=k[i]/10;k[i]%=10;}if(k[i]!=0)l3=i;}
			for(int i=1;i<=this->tail+p.tail;i++){x.b[this->tail+p.tail-i+1]=k[i];if(k[i]!=0 && x.tail==0)x.tail=this->tail+p.tail-i+1;}
			for(int i=this->tail+p.tail+1;i<=l3;i++){x.a[i-this->tail-p.tail]=k[i];if(k[i]!=0)x.head=i-this->tail-p.tail;}
			return x;
		}
		inline decimal operator / (decimal p)
		{
			bignum g,f;
			decimal x;
			decimal s1,s10;s1=1.0;s10=10.0;
			g.tail=0;
			while(*this<s1 || p<s1)
			{
				*this=(*this)*s10;
				p=p*s10;
			}
			int l[Mint+Mdec+Mlim],r[Mint+Mdec+Mlim],k[Mint+Mdec+Mlim],l1=0;
			if(this->head!=1 || this->a[1]!=0)for(int i=this->head;i>=1;i--)l[++l1]=this->a[i];
			for(int i=1;i<=this->tail;i++)l[++l1]=this->b[i];
			for(int i=p.tail;i>=1;i--)g.a[++g.tail]=p.b[i];
			if(p.head!=1 || p.a[1]!=0)for(int i=1;i<=p.head;i++)g.a[++g.tail]=p.a[i];
			for(int i=1;i<=Mlim;i++){f=f*10;f=f+l[i];while(g<=f){f=f-g;k[i]++;}}
			x.head=0;x.tail=0;
			int o=0;
			while(k[o]==0)o++;
			for(int i=this->head+p.tail;i>=o;i--)x.a[++x.head]=k[i];
			if(x.head==0)x.head=1;
			for(int i=this->head+p.tail+1;i<=Mlim;i++)x.b[++x.tail]=k[i];
			return x;
		}
		inline decimal operator *= (const decimal b){*this=(*this*b);return *this;}
		inline decimal operator /= (const decimal b){*this=(*this/b);return *this;}
	};
	std::ostream &operator << (std::ostream &out,decimal &a){a.print(Mlim);return out;}
	std::istream &operator >> (std::istream &in,decimal &a){a.get();return in;}
}

int n;
double a[101][102];
double sub[101];
bool test()
{
	f::decimal x,s1;
	s1=1000000000;
	x.get();
	freopen("xxx.in","r",stdin);
	freopen("gauss.in","r",stdin);
	R(n);
	if(x>s1)return true;
	return false;
}
f::decimal A[101][102];
f::decimal Sub[101];
f::decimal s0;
f::decimal now;
void GAOJ()
{
	s0=0;
	rep(i,n)rep(j,n)A[i][j].get();
	rep(i,n)A[i][n+1].get();
	rep(i,n-1)
	{  
		if(A[i][i]==s0)
			for(int j=i+1;j<=n;j++)
				if(A[j][i]!=s0)
				{
					for(int k=i;k<=n+1;k++)swap(A[i][k],A[j][k]);
					break;
				}
		for(int j=i+1;j<=n;j++)
		{
			now=A[j][i]/A[i][i];
			for(int k=i;k<=n+1;k++)A[j][k]-=A[i][k]*now;
		}
	}
	for(int i=n;i>=1;i--)
	{
		now=A[i][n+1];
		for(int j=1;j<=n-i;j++)now-=A[i][n+1-j]*Sub[n+1-j];
		Sub[i]=now/A[i][i];
	}
	//rep(i,n)printf("%d
",int(Sub[i]+0.5)); rep(i,n) { Sub[i].print(0); printf("
"); } exit(0); } int main() { freopen("gauss.in","r",stdin); freopen("gauss.out","w",stdout); R(n);int X; if(test())GAOJ(); rep(i,n)rep(j,n)R(X),a[i][j]=(double)X; rep(i,n)R(X),a[i][n+1]=(double)X; rep(i,n-1) { if(a[i][i]==0) for(int j=i+1;j<=n;j++) if(a[j][i]!=0) { for(int k=i;k<=n+1;k++)swap(a[i][k],a[j][k]); break; } for(int j=i+1;j<=n;j++) { double now=a[j][i]/a[i][i]; for(int k=i;k<=n+1;k++)a[j][k]-=a[i][k]*now; } } for(int i=n;i>=1;i--) { double now=a[i][n+1]; for(int j=1;j<=n-i;j++)now+=-a[i][n+1-j]*sub[n+1-j]; sub[i]=now/a[i][i]; } rep(i,n)printf("%d
",int(sub[i]+0.5)); return 0; }

좋은 웹페이지 즐겨찾기