/***************************************
*                                      *
*                 集計                 *
*                                      *
*                                      *
***************************************/

#include <iostream>
#include <cstdlib>
#include "snaps.h"
#include "kisoritu.h"
#include "kisosu.h"
#include "cntl.h"

void shke( int nendo , int shubetu )
{
	// 変数宣言
	int sotai_nendo;
	int nenrei;
	int jukyu_nenrei;
	int kikan;
	int dankai;
	int kokko;
	int tokyu;
	int counter;
	double Waribikiritu[2][69 - 66 + 1][2012 - 2008 + 1];
	
	using namespace std;
	
	// 相対年度の定義
	sotai_nendo = nendo - SHONENDO;
	if( sotai_nendo < 0 )
	{
		cout << "年度エラー" << endl;
		exit( 1 );
	}	
	
	// 被保険者数の集計
	for( nenrei = MIN_HIHO_NENREI ; nenrei <= MAX_HIHO_NENREI ; nenrei++ )
	{
		for( kikan = 0 ; kikan <= MAX_HIHO_KIKAN ; kikan++ )
		{
			Hiho_Kei[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI] += Hihokensha[nenrei - MIN_HIHO_NENREI][kikan].ninzu;
			Hiho_Noufu[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI]
			 += Hihokensha[nenrei - MIN_HIHO_NENREI][kikan].ninzu * Noufuritu_Santei[sotai_nendo][nenrei - MIN_HIHO_NENREI];
			Fuka_Hiho[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI]
			 += Hihokensha[nenrei - MIN_HIHO_NENREI][kikan].ninzu * Noufuritu_Fuka[sotai_nendo][nenrei - MIN_HIHO_NENREI];
			
			if( nendo == SAISHUNENDO )
			{
				Hiho_Noufu_P[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI]
				 += Hihokensha[nenrei - MIN_HIHO_NENREI][kikan].ninzu * Noufuritu_Santei[sotai_nendo][nenrei - MIN_HIHO_NENREI];
				Fuka_Hiho_P[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI]
				 += Hihokensha[nenrei - MIN_HIHO_NENREI][kikan].ninzu * Noufuritu_Fuka[sotai_nendo][nenrei - MIN_HIHO_NENREI];
			}
			else
			{
				Hiho_Noufu_P[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI]
				 += Hihokensha[nenrei - MIN_HIHO_NENREI][kikan].ninzu * Noufuritu_Santei[sotai_nendo + 1][nenrei - MIN_HIHO_NENREI];
				Fuka_Hiho_P[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI]
				 += Hihokensha[nenrei - MIN_HIHO_NENREI][kikan].ninzu * Noufuritu_Fuka[sotai_nendo + 1][nenrei - MIN_HIHO_NENREI];
			}
			
			for( dankai = 1 ; dankai <= MAX_MENJO - 1 ; dankai++ )
			{
				Hiho_Menjo[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI][dankai]
				 += Hihokensha[nenrei - MIN_HIHO_NENREI][kikan].ninzu * Menjoritu_Santei[sotai_nendo][nenrei - MIN_HIHO_NENREI][dankai];
				
				if( nendo == SAISHUNENDO )
				{
					Hiho_Menjo_P[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI][dankai]
					 += Hihokensha[nenrei - MIN_HIHO_NENREI][kikan].ninzu * Menjoritu_Santei[sotai_nendo][nenrei - MIN_HIHO_NENREI][dankai];
				}
				else
				{
					Hiho_Menjo_P[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI][dankai]
					 += Hihokensha[nenrei - MIN_HIHO_NENREI][kikan].ninzu * Menjoritu_Santei[sotai_nendo + 1][nenrei - MIN_HIHO_NENREI][dankai];
				}
			}
		}
	}
	for( nenrei = MIN_HIHO_NENREI ; nenrei <= MAX_HIHO_NENREI ; nenrei++ )
	{
		Hiho_Kei[shubetu][sotai_nendo][HIHO_NENREI_SUM] += Hiho_Kei[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI];
		Hiho_Noufu[shubetu][sotai_nendo][HIHO_NENREI_SUM] += Hiho_Noufu[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI];
		Fuka_Hiho[shubetu][sotai_nendo][HIHO_NENREI_SUM] += Fuka_Hiho[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI];
		Hiho_Noufu_P[shubetu][sotai_nendo][HIHO_NENREI_SUM] += Hiho_Noufu_P[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI];
		Fuka_Hiho_P[shubetu][sotai_nendo][HIHO_NENREI_SUM] += Fuka_Hiho_P[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI];
		for( dankai = 1 ; dankai <= MAX_MENJO - 1 ; dankai++ )
		{
			Hiho_Menjo[shubetu][sotai_nendo][HIHO_NENREI_SUM][dankai] += Hiho_Menjo[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI][dankai];
			Hiho_Menjo_P[shubetu][sotai_nendo][HIHO_NENREI_SUM][dankai] += Hiho_Menjo_P[shubetu][sotai_nendo][nenrei - MIN_HIHO_NENREI][dankai];
		}
	}
	// パート適用拡大
	if( nendo == 2016 )
	{
		for( nenrei = MIN_HIHO_NENREI ; nenrei <= MAX_HIHO_NENREI ; nenrei++ )
		{
			for( counter = 0 ; counter <= 1 ; counter++ )
			{
				Part_Taishou[shubetu][1][HIHO_NENREI_SUM][counter] += Part_Taishou[shubetu][1][nenrei - MIN_HIHO_NENREI][counter];
				Part_Noufu[shubetu][1][nenrei - MIN_HIHO_NENREI][counter]
				 = Part_Taishou[shubetu][1][nenrei - MIN_HIHO_NENREI][counter] * Noufuritu_Santei[sotai_nendo][nenrei - MIN_HIHO_NENREI];
				Part_Noufu[shubetu][1][HIHO_NENREI_SUM][counter] += Part_Noufu[shubetu][1][nenrei - MIN_HIHO_NENREI][counter];
				Part_Fuka[shubetu][1][nenrei - MIN_HIHO_NENREI][counter]
				 = Part_Taishou[shubetu][1][nenrei - MIN_HIHO_NENREI][counter] * Noufuritu_Fuka[sotai_nendo][nenrei - MIN_HIHO_NENREI];
				Part_Fuka[shubetu][1][HIHO_NENREI_SUM][counter] += Part_Fuka[shubetu][1][nenrei - MIN_HIHO_NENREI][counter];
				for( dankai = 1 ; dankai <= MAX_MENJO - 1 ; dankai++ )
				{
					Part_Menjo[shubetu][1][nenrei - MIN_HIHO_NENREI][dankai][counter]
					 = Part_Taishou[shubetu][1][nenrei - MIN_HIHO_NENREI][counter] * Menjoritu_Santei[sotai_nendo][nenrei - MIN_HIHO_NENREI][dankai];
					Part_Menjo[shubetu][1][HIHO_NENREI_SUM][dankai][counter] += Part_Menjo[shubetu][1][nenrei - MIN_HIHO_NENREI][dankai][counter];
				}
			}
		}
	}
	if( ( Option2 == 1 || Option2 == 2 ) && nendo == 2024 )
	{
		for( nenrei = MIN_HIHO_NENREI ; nenrei <= MAX_HIHO_NENREI ; nenrei++ )
		{
			for( counter = 0 ; counter <= 1 ; counter++ )
			{
				Part_Taishou[shubetu][2][HIHO_NENREI_SUM][counter] += Part_Taishou[shubetu][2][nenrei - MIN_HIHO_NENREI][counter];
				Part_Noufu[shubetu][2][nenrei - MIN_HIHO_NENREI][counter]
				 = Part_Taishou[shubetu][2][nenrei - MIN_HIHO_NENREI][counter] * Noufuritu_Santei[sotai_nendo][nenrei - MIN_HIHO_NENREI];
				Part_Noufu[shubetu][2][HIHO_NENREI_SUM][counter] += Part_Noufu[shubetu][2][nenrei - MIN_HIHO_NENREI][counter];
				Part_Fuka[shubetu][2][nenrei - MIN_HIHO_NENREI][counter]
				 = Part_Taishou[shubetu][2][nenrei - MIN_HIHO_NENREI][counter] * Noufuritu_Fuka[sotai_nendo][nenrei - MIN_HIHO_NENREI];
				Part_Fuka[shubetu][2][HIHO_NENREI_SUM][counter] += Part_Fuka[shubetu][2][nenrei - MIN_HIHO_NENREI][counter];
				for( dankai = 1 ; dankai <= MAX_MENJO - 1 ; dankai++ )
				{
					Part_Menjo[shubetu][2][nenrei - MIN_HIHO_NENREI][dankai][counter]
					 = Part_Taishou[shubetu][2][nenrei - MIN_HIHO_NENREI][counter] * Menjoritu_Santei[sotai_nendo][nenrei - MIN_HIHO_NENREI][dankai];
					Part_Menjo[shubetu][2][HIHO_NENREI_SUM][dankai][counter] += Part_Menjo[shubetu][2][nenrei - MIN_HIHO_NENREI][dankai][counter];
				}
			}
		}
	}
	
	// 支給額への変換
	// 老齢年金
	for( jukyu_nenrei = MIN_ROREI_JUKYU ; jukyu_nenrei <= 70 ; jukyu_nenrei++ )
	{
		for( nenrei = MIN_ROREI_JUKYU ; nenrei <= MAX_ROREI_JUKYU ; nenrei++ )
		{
			Rorei_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU]
			 = multiply( Shikyuritu_Rorei[nendo - SHONENDO][nenrei - MIN_ROREI_JUKYU]
			           , add( Rorei_Nendomatu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU]
			                , Rorei_Ichibu_Nendomatu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] ) );
			
			Rorei_Kyu_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU]
			 = multiply( Shikyuritu_Rorei_Kyu[nendo - SHONENDO][nenrei - MIN_ROREI_JUKYU]
			           , Rorei_Kyu_Nendomatu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
			
			Turo_Kyu_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU]
			 = multiply( Shikyuritu_Turo_Kyu[nendo - SHONENDO][nenrei - MIN_ROREI_JUKYU]
			           , Turo_Kyu_Nendomatu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
			
			Gonen_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU]
			 = scalar( Shikyuritu_Gonen[nendo - SHONENDO][nenrei - MIN_ROREI_JUKYU]
			         , Gonen_Nendomatu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
			
			// 足下高齢待期者に係る給付費は７０歳にかけて徐々に出す
		  if( shubetu <= 3 )
			{
				Waribikiritu[0][66 - 66][2012 - 2012] = 0.320203;
				Waribikiritu[0][66 - 66][2013 - 2012] = 0.488785;
				Waribikiritu[0][66 - 66][2014 - 2012] = 0.620268;
				Waribikiritu[0][66 - 66][2015 - 2012] = 0.772231;
				Waribikiritu[0][66 - 66][2016 - 2012] = 1.;
				
				Waribikiritu[0][67 - 66][2012 - 2012] = 0.247988;
				Waribikiritu[0][67 - 66][2013 - 2012] = 0.441405;
				Waribikiritu[0][67 - 66][2014 - 2012] = 0.664945;
				Waribikiritu[0][67 - 66][2015 - 2012] = 1.;
				Waribikiritu[0][67 - 66][2016 - 2012] = 1.;
				
				Waribikiritu[0][68 - 66][2012 - 2012] = 0.257198;
				Waribikiritu[0][68 - 66][2013 - 2012] = 0.554455;
				Waribikiritu[0][68 - 66][2014 - 2012] = 1.;
				Waribikiritu[0][68 - 66][2015 - 2012] = 1.;
				Waribikiritu[0][68 - 66][2016 - 2012] = 1.;
				
				Waribikiritu[0][69 - 66][2012 - 2012] = 0.400184;
				Waribikiritu[0][69 - 66][2013 - 2012] = 1.;
				Waribikiritu[0][69 - 66][2014 - 2012] = 1.;
				Waribikiritu[0][69 - 66][2015 - 2012] = 1.;
				Waribikiritu[0][69 - 66][2016 - 2012] = 1.;
				
				
				Waribikiritu[1][66 - 66][2012 - 2012] = 0.320203;
				Waribikiritu[1][66 - 66][2013 - 2012] = 0.501563;
				Waribikiritu[1][66 - 66][2014 - 2012] = 0.652981;
				Waribikiritu[1][66 - 66][2015 - 2012] = 0.839500;
				Waribikiritu[1][66 - 66][2016 - 2012] = 1.131367;
				
				Waribikiritu[1][67 - 66][2012 - 2012] = 0.247988;
				Waribikiritu[1][67 - 66][2013 - 2012] = 0.455033;
				Waribikiritu[1][67 - 66][2014 - 2012] = 0.710075;
				Waribikiritu[1][67 - 66][2015 - 2012] = 1.109167;
				Waribikiritu[1][67 - 66][2016 - 2012] = 1.109167;
				
				Waribikiritu[1][68 - 66][2012 - 2012] = 0.257198;
				Waribikiritu[1][68 - 66][2013 - 2012] = 0.574022;
				Waribikiritu[1][68 - 66][2014 - 2012] = 1.069789;
				Waribikiritu[1][68 - 66][2015 - 2012] = 1.069789;
				Waribikiritu[1][68 - 66][2016 - 2012] = 1.069789;
				
				Waribikiritu[1][69 - 66][2012 - 2012] = 0.400184;
				Waribikiritu[1][69 - 66][2013 - 2012] = 1.026393;
				Waribikiritu[1][69 - 66][2014 - 2012] = 1.026393;
				Waribikiritu[1][69 - 66][2015 - 2012] = 1.026393;
				Waribikiritu[1][69 - 66][2016 - 2012] = 1.026393;
			}
			else
			{
				Waribikiritu[0][66 - 66][2011 - 2011] = 0.345477;
				Waribikiritu[0][66 - 66][2012 - 2011] = 0.509453;
				Waribikiritu[0][66 - 66][2013 - 2011] = 0.638261;
				Waribikiritu[0][66 - 66][2014 - 2011] = 0.764631;
				Waribikiritu[0][66 - 66][2015 - 2011] = 1.;
				
				Waribikiritu[0][67 - 66][2011 - 2011] = 0.250528;
				Waribikiritu[0][67 - 66][2012 - 2011] = 0.447325;
				Waribikiritu[0][67 - 66][2013 - 2011] = 0.640397;
				Waribikiritu[0][67 - 66][2014 - 2011] = 1.;
				Waribikiritu[0][67 - 66][2015 - 2011] = 1.;
				
				Waribikiritu[0][68 - 66][2011 - 2011] = 0.262580;
				Waribikiritu[0][68 - 66][2012 - 2011] = 0.520192;
				Waribikiritu[0][68 - 66][2013 - 2011] = 1.;
				Waribikiritu[0][68 - 66][2014 - 2011] = 1.;
				Waribikiritu[0][68 - 66][2015 - 2011] = 1.;
				
				Waribikiritu[0][69 - 66][2011 - 2011] = 0.349341;
				Waribikiritu[0][69 - 66][2012 - 2011] = 1.;
				Waribikiritu[0][69 - 66][2013 - 2011] = 1.;
				Waribikiritu[0][69 - 66][2014 - 2011] = 1.;
				Waribikiritu[0][69 - 66][2015 - 2011] = 1.;
				
				
				Waribikiritu[1][66 - 66][2011 - 2011] = 0.345477;
				Waribikiritu[1][66 - 66][2012 - 2011] = 0.521883;
				Waribikiritu[1][66 - 66][2013 - 2011] = 0.670219;
				Waribikiritu[1][66 - 66][2014 - 2011] = 0.825326;
				Waribikiritu[1][66 - 66][2015 - 2011] = 1.126931;
				
				Waribikiritu[1][67 - 66][2011 - 2011] = 0.250528;
				Waribikiritu[1][67 - 66][2012 - 2011] = 0.461191;
				Waribikiritu[1][67 - 66][2013 - 2011] = 0.681472;
				Waribikiritu[1][67 - 66][2014 - 2011] = 1.109804;
				Waribikiritu[1][67 - 66][2015 - 2011] = 1.109804;
				
				Waribikiritu[1][68 - 66][2011 - 2011] = 0.262580;
				Waribikiritu[1][68 - 66][2012 - 2011] = 0.537148;
				Waribikiritu[1][68 - 66][2013 - 2011] = 1.071042;
				Waribikiritu[1][68 - 66][2014 - 2011] = 1.071042;
				Waribikiritu[1][68 - 66][2015 - 2011] = 1.071042;
				
				Waribikiritu[1][69 - 66][2011 - 2011] = 0.349341;
				Waribikiritu[1][69 - 66][2012 - 2011] = 1.028631;
				Waribikiritu[1][69 - 66][2013 - 2011] = 1.028631;
				Waribikiritu[1][69 - 66][2014 - 2011] = 1.028631;
				Waribikiritu[1][69 - 66][2015 - 2011] = 1.028631;
			}
			
			if( ( jukyu_nenrei == 66 && nendo - nenrei == 1946 ) || ( jukyu_nenrei == 67 && nendo - nenrei == 1945 )
		     || ( jukyu_nenrei == 68 && nendo - nenrei == 1944 ) || ( jukyu_nenrei == 69 && nendo - nenrei == 1943 ) )
			{
				if( nendo >= 2012 && nendo <= 2016 )
				{
					Rorei_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU].ninzu *= Waribikiritu[0][jukyu_nenrei - 66][nendo - 2012];
					Rorei_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU]
					 = adjustbenefit( Waribikiritu[1][jukyu_nenrei - 66][nendo - 2012] , Rorei_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
				}
				else if( nendo >= 2017 )
				{
					Rorei_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU].ninzu *= Waribikiritu[0][jukyu_nenrei - 66][2016 - 2012];
					Rorei_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU]
					 = adjustbenefit( Waribikiritu[1][jukyu_nenrei - 66][2016 - 2012] , Rorei_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
				}
			}
			
			
			// 年度末値の作成
			if( nenrei <= 63 )
			{
				Rorei[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				 = add( Rorei[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				      , Rorei_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
				
				Rorei_Kyu[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				 = add( Rorei_Kyu[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				      , Rorei_Kyu_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
				
				Turo_Kyu[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				 = add( Turo_Kyu[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				      , Turo_Kyu_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
				
				Gonen[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				 = add( Gonen[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				      , Gonen_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
			}
			else
			{
				Rorei[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				 = add( Rorei[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				      , Rorei_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
				
				Rorei_Kyu[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				 = add( Rorei_Kyu[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				      , Rorei_Kyu_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
				
				Turo_Kyu[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				 = add( Turo_Kyu[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				      , Turo_Kyu_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
				
				Gonen[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				 = add( Gonen[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU]
				      , Gonen_Shikyu[nenrei - MIN_ROREI_JUKYU][jukyu_nenrei - MIN_ROREI_JUKYU] );
			}
		}
	}
	// 免除計
	for( jukyu_nenrei = MIN_ROREI_JUKYU ; jukyu_nenrei <= 70 ; jukyu_nenrei++ )
	{
		for( nenrei = UNDER_63 ; nenrei <= MAX_ROREI_JUKYU ; nenrei++ )
		{	
			for( dankai = 1 ; dankai <= MAX_MENJO - 1 ; dankai++ )
			{
				
				for( kokko = 1 ; kokko <= KOKKO_HIKIAGE - 1 ; kokko++ )
				{
					Rorei[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU].menjo[SUM][kokko]
					 += Rorei[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU].menjo[dankai][kokko];
					
					Rorei[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU].menjo[dankai][SUM]
					 += Rorei[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU].menjo[dankai][kokko];
					
					Rorei[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU].menjo[SUM][SUM]
					 += Rorei[shubetu][sotai_nendo][nenrei - NENREI_SUM][jukyu_nenrei - MIN_ROREI_JUKYU].menjo[dankai][kokko];
				}
			}
		}
	}
	
	// 障害年金
	for( tokyu = 1 ; tokyu <= 2 ; tokyu++ )
	{
		for( nenrei = MIN_SHOGAI_JUKYU ; nenrei <= MAX_SHOGAI_JUKYU ; nenrei++ )
		{
			Shogai_Ippan_Shikyu[nenrei - MIN_SHOGAI_JUKYU][tokyu]
			 = scalar( Shikyuritu_Shogai_Ippan[nendo - SHONENDO][nenrei - MIN_SHOGAI_JUKYU][tokyu]
			         , Shogai_Ippan_Nendomatu[nenrei - MIN_SHOGAI_JUKYU][tokyu] );
			
			Shogai_20mae_Shikyu[nenrei - MIN_SHOGAI_JUKYU][tokyu]
			 = scalar( Shikyuritu_Shogai_20mae[nendo - SHONENDO][nenrei - MIN_SHOGAI_JUKYU][tokyu]
			         , Shogai_20mae_Nendomatu[nenrei - MIN_SHOGAI_JUKYU][tokyu] );
			
			Shogai_Kyu_Shikyu[nenrei - MIN_SHOGAI_JUKYU][tokyu]
			 = scalar( Shikyuritu_Shogai_Kyu[nendo - SHONENDO][nenrei - MIN_SHOGAI_JUKYU][tokyu]
			         , Shogai_Kyu_Nendomatu[nenrei - MIN_SHOGAI_JUKYU][tokyu] );
			
			
			if( nenrei <= 63 )
			{
				Shogai_Ippan[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM]
				 = add( Shogai_Ippan[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM] , Shogai_Ippan_Shikyu[nenrei - MIN_SHOGAI_JUKYU][tokyu] );
				
				Shogai_20mae[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM]
				 = add( Shogai_20mae[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM] , Shogai_20mae_Shikyu[nenrei - MIN_SHOGAI_JUKYU][tokyu] );
				
				Shogai_Kyu[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM]
				 = add( Shogai_Kyu[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM] , Shogai_Kyu_Shikyu[nenrei - MIN_SHOGAI_JUKYU][tokyu] );
			}
			else
			{
				Shogai_Ippan[shubetu][sotai_nendo][nenrei - NENREI_SUM]
				 = add( Shogai_Ippan[shubetu][sotai_nendo][nenrei - NENREI_SUM] , Shogai_Ippan_Shikyu[nenrei - MIN_SHOGAI_JUKYU][tokyu] );
				
				Shogai_20mae[shubetu][sotai_nendo][nenrei - NENREI_SUM]
				 = add( Shogai_20mae[shubetu][sotai_nendo][nenrei - NENREI_SUM] , Shogai_20mae_Shikyu[nenrei - MIN_SHOGAI_JUKYU][tokyu] );
				
				Shogai_Kyu[shubetu][sotai_nendo][nenrei - NENREI_SUM]
				 = add( Shogai_Kyu[shubetu][sotai_nendo][nenrei - NENREI_SUM] , Shogai_Kyu_Shikyu[nenrei - MIN_SHOGAI_JUKYU][tokyu] );
			}
		}
	}
	
	// 遺族年金（妻）
	for( nenrei = MIN_IZOKU_TUMA_JUKYU ; nenrei <= MAX_IZOKU_TUMA_JUKYU ; nenrei++ )
	{
		Izoku_Tuma_Shikyu[nenrei - MIN_IZOKU_TUMA_JUKYU]
		 = scalar( Shikyuritu_Tuma[nendo - SHONENDO] , Izoku_Tuma_Nendomatu[nenrei - MIN_IZOKU_TUMA_JUKYU] );
		
		if( nenrei <= 63 )
		{
			Izoku_Tuma[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM]
			 = add( Izoku_Tuma[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM] , Izoku_Tuma_Shikyu[nenrei - MIN_IZOKU_TUMA_JUKYU] );
		}
		else
		{
			Izoku_Tuma[shubetu][sotai_nendo][nenrei - NENREI_SUM]
			 = add( Izoku_Tuma[shubetu][sotai_nendo][nenrei - NENREI_SUM] , Izoku_Tuma_Shikyu[nenrei - MIN_IZOKU_TUMA_JUKYU] );
		}
	}
	
	// 遺族年金（夫）
	for( nenrei = MIN_IZOKU_OTTO_JUKYU ; nenrei <= MAX_IZOKU_OTTO_JUKYU ; nenrei++ )
	{
		Izoku_Otto_Shikyu[nenrei - MIN_IZOKU_OTTO_JUKYU]
		 = scalar( Shikyuritu_Otto[nendo - SHONENDO] , Izoku_Otto_Nendomatu[nenrei - MIN_IZOKU_OTTO_JUKYU] );
		
		if( nenrei <= 63 )
		{
			Izoku_Otto[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM]
			 = add( Izoku_Otto[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM] , Izoku_Otto_Shikyu[nenrei - MIN_IZOKU_OTTO_JUKYU] );
		}
		else
		{
			Izoku_Otto[shubetu][sotai_nendo][nenrei - NENREI_SUM]
			 = add( Izoku_Otto[shubetu][sotai_nendo][nenrei - NENREI_SUM] , Izoku_Otto_Shikyu[nenrei - MIN_IZOKU_OTTO_JUKYU] );
		}
	}
	
	// 遺族年金（子）
	for( nenrei = MIN_IZOKU_KO_JUKYU ; nenrei <= MAX_IZOKU_KO_JUKYU ; nenrei++ )
	{
		Izoku_Ko_Shikyu[nenrei - MIN_IZOKU_KO_JUKYU]
		 = scalar( Shikyuritu_Ko[nendo - SHONENDO] , Izoku_Ko_Nendomatu[nenrei - MIN_IZOKU_KO_JUKYU] );
		
		Izoku_Ko[shubetu][sotai_nendo] = add( Izoku_Ko[shubetu][sotai_nendo] , Izoku_Ko_Shikyu[nenrei - MIN_IZOKU_KO_JUKYU]  );
	}
	
	// 寡婦年金
	for( nenrei = 60 ; nenrei <= MAX_KAFU_JUKYU ; nenrei++ )
	{
		Kafu_Shikyu[nenrei - MIN_KAFU_JUKYU]
		 = scalar( Shikyuritu_Kafu[nendo - SHONENDO][nenrei - 60] , Kafu_Nendomatu[nenrei - MIN_KAFU_JUKYU] );
		Kafu_Kyu_Shikyu[nenrei - MIN_KAFU_JUKYU]
		 = scalar( Shikyuritu_Kafu[nendo - SHONENDO][nenrei - 60] , Kafu_Kyu_Nendomatu[nenrei - MIN_KAFU_JUKYU] );
		
		Kafu[shubetu][sotai_nendo] = add( Kafu[shubetu][sotai_nendo] , Kafu_Shikyu[nenrei - MIN_KAFU_JUKYU] );
		Kafu_Kyu[shubetu][sotai_nendo] = add( Kafu_Kyu[shubetu][sotai_nendo] , Kafu_Kyu_Shikyu[nenrei - MIN_KAFU_JUKYU] );
	}
	
	// 免除計
	for( dankai = 1 ; dankai <= MAX_MENJO - 1 ; dankai++ )
	{
		for( kokko = 1 ; kokko <= KOKKO_HIKIAGE - 1 ; kokko++ )
		{
			Kafu[shubetu][sotai_nendo].menjo[SUM][kokko] += Kafu[shubetu][sotai_nendo].menjo[dankai][kokko];
			Kafu_Kyu[shubetu][sotai_nendo].menjo[SUM][kokko] += Kafu_Kyu[shubetu][sotai_nendo].menjo[dankai][kokko];
			
			Kafu[shubetu][sotai_nendo].menjo[dankai][SUM] += Kafu[shubetu][sotai_nendo].menjo[dankai][kokko];
			Kafu_Kyu[shubetu][sotai_nendo].menjo[dankai][SUM] += Kafu_Kyu[shubetu][sotai_nendo].menjo[dankai][kokko];
			
			Kafu[shubetu][sotai_nendo].menjo[SUM][SUM] += Kafu[shubetu][sotai_nendo].menjo[dankai][kokko];
			Kafu_Kyu[shubetu][sotai_nendo].menjo[SUM][SUM] += Kafu_Kyu[shubetu][sotai_nendo].menjo[dankai][kokko];
		}
	}
	
	// 死亡一時金
	for( nenrei = MIN_HIHO_NENREI ; nenrei <= MAX_HIHO_NENREI ; nenrei++ )
	{
		if( nenrei <= 63 )
		{
			Ichijikin[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM]
			 = add( Ichijikin[shubetu][sotai_nendo][UNDER_63 - NENREI_SUM] , Ichijikin_Nendomatu[nenrei - MIN_HIHO_NENREI] );
		}
		else
		{
			Ichijikin[shubetu][sotai_nendo][nenrei - NENREI_SUM]
			 = add( Ichijikin[shubetu][sotai_nendo][nenrei - NENREI_SUM] , Ichijikin_Nendomatu[nenrei - MIN_HIHO_NENREI] );
		}
	}
}
